Moving a platform app's data (#647)

A platform app's Postgres goes through the app's drop into the forge app's own store, with a receipt, and can be taken back until a domain is cut over. It is the data line of the migration checklist (docs/features/migration-mode.md); the engine under it is the database import in docs/features/platform-app-move.md.

The path

  1. Make the dump where the old database is reachable. The page shows the one command

(EXPORT_COMMAND, src/apps/pg_dump.ts): pg_dump --inserts --no-owner --no-privileges --no-comments "$DATABASE_URL" > dump.sql. The connection string stays on that machine; the forge never receives it. (The forge running pg_dump itself with a connection string given once was left out: it needs a Postgres client and an egress entry to a host the owner names.)

  1. Put it in the drop (/<owner>/<name>/drop, up to 16 MB for an import).
  2. Check, then import, at /<owner>/<name>/data-move, reached from Import data on the app

page's migration card. Check does everything but put the file in place; Import first keeps the store it replaces as app.db.before-import-<ms> (the snapshot), then replaces it.

  1. The receipt: per table the rows and SHA-256 on the dump's side and on the store's, and the

rows counted from the dump's own text. Import happens only when all agree. What a Postgres dump has that SQLite has no meaning for (session SETs, set_config, setval, ownership, column defaults, ALTER TABLE constraints, sequences, comments, extensions, schemas) is left out, counted, and shown on the receipt. Primary, unique and foreign keys are not kept: the tables load without them, and the receipt says so; public. is dropped from names. COPY is refused: dump with --inserts. Anything else the import's vetting refuses by statement number (SELECT, functions, UPDATE).

  1. Undo puts the snapshot back and sets the imported store aside as

app.db.undone-import-<ms>; nothing is deleted. When there was no store before, the imported one is set aside and the app starts empty as it was. It is open until a domain of the app is verified and has its old DNS recorded (the cut-over, app_domain.old_records); then an import and an undo are both refused, since the old data is no longer the way back.

The record is the app.data_imported and app.data_undone events (the first carries the snapshot's name and each table's rows and checksum): no state of its own.

Doors (all a repository admin's; anyone else gets not found)

imports, { undo: true } undoes; an admin-scope token for POST.

dumps and the last receipt; dump is a dry run; apply/undo need an admin-scope token.

a imports it, u undoes after a y/n.

Not done

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs