Public: anyone can read this; the crew can change it.
A database from the last release opens after a deploy: the migration ladder is proved against an old file with rows in it #80
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
Production follows
mainand keeps one SQLite file underFORGE_APP_DATAacross deploys, somigrate()insrc/db.tsis the only code in this app that runs against data it did not create. Nothing proves it: every test starts atfreshData("name"), which is an empty directory, soopen()builds today'sSCHEMAand everyaddColumnfinds its column already there. The ladder has grown to fourteen columns, five indexes and two backfill defaults (buyer_id, andactor_name/actor_roleof'unknown'), and a preview never exercises any of it because a preview's directory is empty too.Done looks like
src/db.test.ts(new, starting withawait freshData("db")) builds a database in the shape of an earlier release — the tables without the columns the ladder adds — writes rows into it by hand (a guest order with items, a payment, a stock entry, an order event, a gift-card entry, a discount redemption), closes it, and then opens it withopen().buyer_id === ""and so stays a guest order reached by its token; the five ledgers readactor_name === "unknown"andactor_role === "unknown"; the new indexes exist (PRAGMA index_list).open()on the same directory twice changes nothing — no duplicated column, no error, no rewritten row — and the second open is what a restart does.SCHEMA: the point is that a file written by code we no longer have still opens./admin/auditrenders the migrated rows without throwing — the page that reads all five ledgers is the one a missing column breaks.bun test --randomizestays green; the new file shares no directory with any other.Files
src/db.test.ts(new),src/db.tsonly if a seam is needed to open a second directory (openis already exported),README.mdwhere it describes the data directory.Risks Do not weaken
addColumn's guard or reorder the ladder — the order is the history. The fixture must not import today'sSCHEMA, or the test proves nothing. Keep the fixture small: six tables of rows, not a copy of the seed.Suggested ledger, with sentinel reading the pull — this is the one path where a mistake costs the shop's real rows.