summaryrefslogtreecommitdiff
path: root/docs/SCHEMA.md
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-20 09:51:28 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-20 09:51:28 +0200
commitb5349b52e757399d8ddb6325120a58e7d9e6e1f6 (patch)
treefa6771abbcaf5c654968d5e8c5ff27c0ec292564 /docs/SCHEMA.md
parent67179a7ae9f6e399701434775a2ef345367b76bf (diff)
downloadbokf-b5349b52e757399d8ddb6325120a58e7d9e6e1f6.tar.gz
bokf-b5349b52e757399d8ddb6325120a58e7d9e6e1f6.zip
db: snapshot the database before forward migrations
When db_open finds an older schema version, write a consistent VACUUM INTO copy to <backup_dir>/pre-migration-v<old>-<UTC>.db before the first migration statement. A taken name gets a numeric suffix; if the snapshot fails, the open and the migration abort.
Diffstat (limited to 'docs/SCHEMA.md')
-rw-r--r--docs/SCHEMA.md7
1 files changed, 5 insertions, 2 deletions
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-<version>`).
+ one transaction. Before the first migration statement a consistent
+ `VACUUM INTO` snapshot is written to
+ `<backup_dir>/pre-migration-v<old>-<UTC timestamp>.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.