From b5349b52e757399d8ddb6325120a58e7d9e6e1f6 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Sun, 20 Sep 2026 09:51:28 +0200 Subject: db: snapshot the database before forward migrations When db_open finds an older schema version, write a consistent VACUUM INTO copy to /pre-migration-v-.db before the first migration statement. A taken name gets a numeric suffix; if the snapshot fails, the open and the migration abort. --- docs/SCHEMA.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/SCHEMA.md b/docs/SCHEMA.md index 2100990..89dd0b1 100644 --- a/docs/SCHEMA.md +++ b/docs/SCHEMA.md @@ -484,8 +484,11 @@ another voucher is posted in between) — clients must not persist it. and `created_at`. Current version: **3** (v3 replaces the seeded moms rules with the corrected mapping; v2 adds the two template tables). - Migrations are forward-only, applied automatically at daemon start, each in - one transaction, and require an automatic `VACUUM INTO` snapshot next to the - database before starting (`bokfd.db.pre-migration-`). + one transaction. Before the first migration statement a consistent + `VACUUM INTO` snapshot is written to + `/pre-migration-v-.db` (a numeric suffix is + added when the name is taken); if the snapshot cannot be taken the upgrade + is aborted and the database is left at its old version. - `audit.verify` must pass before and after any migration; migrations never rewrite ledger rows. -- cgit v1.3