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.)
  2. Put it in the drop (/<owner>/<name>/drop, up to 16 MB for an import).
  3. 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.
  4. 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).
  5. 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.
  6. The restart (#15266): a running app holds the file it opened at start, and the import renames a new one over it, so once the file is in place an import or an undo deploys production again at its own commit, the same redeploy the app page's button asks for (restartAfterMove, src/actions/migrate_data.ts). Only a running (or coming-up) production is restarted; one asleep or stopped opens the new file when it next starts, so nothing in flight is dropped for it. The result line, the API's and MCP's restart (restarted, asleep, not_running) and the terminal say which.

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)

Not done

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs