Skip to main content

Module data

Module data 

Source
Expand description

fz data export / fz data import (issue #21): moving a venture’s D1 data to Postgres — the migration-path step between “stand up Postgres, run the migrations” and “switch the runtime” (architecture section 10).

Export reads a venture SQLite database — D1 is SQLite, and the Cloudflare-side step is wrangler d1 export loaded into a local SQLite file; docs/DATA-MOVE.md is the runbook. It writes one JSON Lines file: a manifest line first (per-table row counts and sha256, tables in lock order), then one {"table","row"} record per table row, tables in the same lock order.

Import (requires the crate’s postgres feature, like fz migrations apply) loads that file into a Postgres database in lock order: it verifies every table’s sha256 against the manifest, refuses a non-empty table without --append, inserts batched multi-row statements inside one transaction per table, and verifies row counts afterwards. --plan prints what either command would do and writes nothing.

Functions§

export
Exports the venture’s tables from the SQLite database at db_path to out_path as manifest + JSONL records (see the module docs). plan prints the per-table summary without writing.
import
Imports an export file into the Postgres database at url (see the module docs). plan prints the per-table target state without writing.