Reconcile SQL migrations with journal metadata#223

openedJul 18, 2026byAAviddaram

Parent

https://github.com/darjss/vit-store/issues/198

Accepted audit ID: P-04.

What to build

Reconcile migration metadata, declared schema, and read-only environment history; use only forward-compatible repairs for changes proven missing.

Acceptance criteria

  • Every environment comparison is recorded without rewriting applied history.
  • A disposable fresh database reaches the declared schema using the approved forward-only sequence.
  • Applicable existing static/build checks pass, and no unrelated behavior changes.

Blocked by

None — can start immediately

Migration reconciliation stopped at the ownership gate with no repository changes.

Repository inventory at 77f2a3a5c028555f1a3c698dca63dc6a95d8dde7 found 24 SQL files but 21 journal entries. The unjournaled files are:

  • 0011_category_brand_seo.sql
  • 0011_elite_the_santerians.sql
  • 0012_order_payment_uniques_claimed_status.sql

Their DDL overlaps: 0011_elite_the_santerians.sql repeats the brand/category and order/payment changes from the other two files, and also overlaps the separately journaled 0013_messenger_notification_failures.sql. Public git history and runbook/issue history do not prove which overlapping files, if any, were applied manually or through a prior path. The snapshot chain also has an absent predecessor: 0014_snapshot.json.prevId is not the ID of any retained snapshot.

With Drizzle Kit 0.31.5, migration execution reads only journal entries and records each journal timestamp plus the SQL hash. Adding/reordering entries without read-only deployed migration-table/schema evidence could therefore replay, skip, or reorder ambiguously applied DDL. Drizzle generation appends a new timestamped entry/snapshot/SQL file; it cannot canonically reconstruct these historical overlapping entries without inventing metadata.

Unblock requirements: owner-provided read-only migration-table and schema inventory for every deployed environment, plus an ownership decision for the three overlapping SQL files and the missing snapshot predecessor. No production/staging connection or write was attempted, and no secret-bearing config was loaded.