diff --git a/graph/fixes/fix-document-sqlite-synchronous0-pragma-in-paper-dynasty-dat-8028ae.md b/graph/fixes/fix-document-sqlite-synchronous0-pragma-in-paper-dynasty-dat-8028ae.md new file mode 100644 index 00000000000..3e8104dae57 --- /dev/null +++ b/graph/fixes/fix-document-sqlite-synchronous0-pragma-in-paper-dynasty-dat-8028ae.md @@ -0,0 +1,30 @@ +--- +id: 8028aeb5-d922-49aa-b0e6-fbc1cce35484 +type: fix +title: "Fix: Document SQLite synchronous=0 pragma in paper-dynasty-database" +tags: [paper-dynasty, sqlite, peewee, documentation, fix, python, db_engine] +importance: 0.5 +confidence: 0.8 +created: "2026-03-04T01:32:49.610296+00:00" +updated: "2026-03-04T01:32:49.610296+00:00" +--- + +## Problem +`app/db_engine.py:36` had `pragmas={"synchronous": 0}` with no explanation. `synchronous=0` (OFF) skips fsync on writes — fast but risks DB corruption on hard crash. + +## Context +- SQLite branch is **dev-only**; production uses PostgreSQL (`DATABASE_TYPE` env var) +- WAL journal mode (`journal_mode=wal`) partially mitigates the corruption window +- Trade-off is acceptable in dev (data loss tolerable, write speed prioritised) + +## Solution +Added a block comment above the SQLite `SqliteDatabase(...)` call explaining: +- `synchronous=0` behaviour and crash-corruption risk +- Why it's acceptable in dev (not used in production) +- How WAL mode reduces (but doesn't eliminate) the risk + +## Files Changed +- `app/db_engine.py` — comment at SQLite branch (line ~33) + +## PR +https://git.manticorum.com/cal/paper-dynasty-database/pulls/49 (issue #20)