Output ndjson in migration script

This commit is contained in:
Maurus Decimus
2026-04-25 22:17:12 +02:00
parent a35e8b97e4
commit cd4b08544c
2 changed files with 8 additions and 6 deletions

View File

@@ -267,7 +267,7 @@ $ sudo -u stalwart env \
The migration output will scroll past. When it finishes, the process stays in the foreground, listening on port `8080`. Leave this terminal open.
**6. Apply the exported snapshot.** From a **second terminal** (on the same host or any machine that can reach the server on port `8080`), install the new CLI: instructions at https://stalw.art/docs/management/cli/overview: and run:
**6. Apply the exported snapshot.** From a **second terminal** (on the same host or any machine that can reach the server on port `8080`), install the new CLI (*make sure to install v1.0.2 or later*): instructions at https://stalw.art/docs/management/cli/overview: and run:
```bash
$ export STALWART_URL=http://127.0.0.1:8080

View File

@@ -9,8 +9,8 @@ Two modes:
convert — read those two JSON files and emit:
* config.json — plain DataStore object (Stalwart's main config)
* export.json — array of `update`/`create` ops for everything
else, in load order.
* export.json — NDJSON stream of `update`/`create` ops for
everything else, one op per line, in load order.
Usage:
python migrate_v016.py dump --url https://mail.example.com \
@@ -1595,8 +1595,10 @@ def cmd_convert(args: argparse.Namespace) -> int:
ops = build_export_ops(result)
with open(args.output, "w", encoding="utf-8") as f:
json.dump(ops, f, indent=2, ensure_ascii=False)
print(f"wrote {args.output} ({len(ops)} ops)", file=sys.stderr)
for op in ops:
f.write(json.dumps(op, ensure_ascii=False))
f.write("\n")
print(f"wrote {args.output} ({len(ops)} ops, NDJSON)", file=sys.stderr)
for op in ops:
kind = op["@type"]
name = op["object"]
@@ -1635,7 +1637,7 @@ def build_parser() -> argparse.ArgumentParser:
help="Output file for the DataStore object "
"(default: config.json).")
c.add_argument("--output", default="export.json",
help="Output file for the operations array "
help="Output NDJSON file with one operation per line "
"(default: export.json).")
c.set_defaults(func=cmd_convert)