@davoodmehraban89 / Aram-2 Mirror · read-only / commits / 01ab6a2
Fork 0

Mirrored from https://github.com/davoodmehraban89/Aram.git

Synced Dec 3, 19:30 UTC

fix(migrations): refuse audit upgrade over preexisting unwitnessed drafts

davoodmehraban89 committed Oct 30, 2026 at 19:54 UTC 01ab6a28447c27be1378ea48adb97dba6ca4ce72
1 file changed +11
backend/migrations/versions/20261030_03_system_staging_audit.py
+11
@@ -24,6 +24,17 @@ def _require_sqlite() -> None:
24
25 def upgrade() -> None:
26 _require_sqlite()
27 + # PR #53 may already contain real Unreviewed drafts. Creating an empty
28 + # event table would orphan their evidence and make future reads fail.
29 + # Do not invent historical system events: require a separately approved
30 + # documented backfill/recovery plan before upgrading such a database.
31 + if op.get_bind().execute(
32 + sa.text("SELECT 1 FROM mapping_review_drafts LIMIT 1")
33 + ).first() is not None:
34 + raise RuntimeError(
35 + "existing Unreviewed drafts require reviewed audit backfill "
36 + "or recovery before this migration"
37 + )
38 op.create_table(
39 "mapping_draft_events",
40 sa.Column("id", sa.Integer(), primary_key=True),