Phase 9, part 7: export and import, between SQLite and Postgres
supermarket export [--with-secrets] writes a whole Supermarket as a .tar.gz (a manifest, each table as JSON lines, secrets if asked for) to the file storage. supermarket import loads one into an empty database at the same schema, SQLite or Postgres, in one transaction, parents first, checking row counts and moving Postgres' identity counters past the imported ids. Checked on Federated's 112,543 rows: imported into Postgres and SQLite, every table and total matches, and TestPagesOnRealData renders all 57 pages the same from both. That found unsettled ordering (case-alike campaigns, customers with the same name, metrics' float sums), now fixed with ORDER BY and tie-breakers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2002,6 +2002,41 @@ than planned: rather than helpers in every query, the SQL stays as it is
|
||||
server would.
|
||||
- The backup loop stays as it is: it's the local edition's, with one copy.
|
||||
|
||||
**Part 7 built 2026-11-25** on `phase9`. **Phase 9 is built.**
|
||||
- `internal/transfer`: an export is a `.tar.gz` with:
|
||||
- a manifest (format, schema, app version, rows per table, secrets)
|
||||
- each table's rows as JSON lines
|
||||
- with `--with-secrets`, the keys and tokens
|
||||
|
||||
It's written from either database and loaded into either. Left out:
|
||||
running copies, locks, sign-ins under way, the schema bookkeeping.
|
||||
- An import is checked before loading:
|
||||
- The target must be empty, apart from the IndexNow key a new install
|
||||
writes at start, which the export's replaces: the website publishes
|
||||
the old one.
|
||||
- The target must be at the same schema.
|
||||
- Every table in the export must exist there.
|
||||
|
||||
Then everything loads in one transaction, parents before children, in
|
||||
batches. Each table's row count is checked against the manifest, and
|
||||
Postgres' identity counters are moved past the imported ids.
|
||||
- `supermarket export [--with-secrets]` writes to the file storage
|
||||
(`files/exports/` on the local edition). `supermarket import <file>`
|
||||
takes a path or an export's name; the host's command copies a file from
|
||||
elsewhere into the data folder first.
|
||||
- Checked on Federated's install: 112,543 rows in 39 tables, 3.4 MB.
|
||||
- Imported into Postgres in 4 seconds, with every table's count and
|
||||
sample totals the same.
|
||||
- Imported into a new SQLite too. All 57 pages (with each signal's)
|
||||
render the same from both, by `TestPagesOnRealData`.
|
||||
- That comparison found order that wasn't settled, now fixed:
|
||||
- Two campaigns named alike but for case.
|
||||
- Two Stripe customers with the same name and email.
|
||||
- The invoice lines and payments behind Metrics. Read in any order, their
|
||||
float sums put one figure at −$280 or −$281.
|
||||
- Moving a local install into multi-tenant as a new team comes with
|
||||
Phase 13.
|
||||
|
||||
Nothing changes for the local user; this makes the rest possible. A
|
||||
commit after each part; the whole test suite runs against both SQLite and
|
||||
Postgres from part 2 on.
|
||||
|
||||
Reference in New Issue
Block a user