fix(server): restore drizzle meta snapshots + drop dead annotations table #9

Merged
pregno merged 2 commits from fix/drizzle-meta-snapshots into main 2026-06-13 01:30:35 +02:00
Owner

Repairs the broken migration tooling found during the review: _journal.json lists migrations 0000–0007 but meta/ only had snapshots 0000–0002, so drizzle-kit generate diffed against the stale 0002 snapshot and proposed spurious changes — no new migration could be generated.

Repair (commit 1, purely additive): snapshots 0003–0007 were reconstructed by replaying history — for each migration, schema.ts was restored from the commit that added the SQL file, the journal truncated to the preceding entries, and drizzle-kit generate --name <original tag> run; only the snapshot JSON was kept. The committed SQL files and journal are byte-identical to main (verified — deployed DBs track migrations by content, so they must not change). The snapshot id/prevId chain is intact 0002→…→0007.

Notes from the replay: 0003's generated SQL differs in form from the committed hand-written DROP+CREATE but produces the same table shape (verified column-by-column); 0004's committed file prepends a hand-written DELETE dedupe; 0005/0006 were added in one commit so an intermediate schema was built for 0005; 0005–0007 generated byte-identical SQL.

Acceptance: db:generate now reports "No schema changes" (clean no-op); fresh-DB migrate applies all migrations.

Commit 2: with generate working again, the dead annotations table (no repository method, route, or test — re-verified) is dropped via a proper generated 0008_drop_annotations migration.

Tests: 56 files / 311 passing, typecheck clean, fresh-DB migrate verified before and after the drop.

Repairs the broken migration tooling found during the review: `_journal.json` lists migrations 0000–0007 but `meta/` only had snapshots 0000–0002, so `drizzle-kit generate` diffed against the stale 0002 snapshot and proposed spurious changes — no new migration could be generated. **Repair (commit 1, purely additive):** snapshots 0003–0007 were reconstructed by replaying history — for each migration, schema.ts was restored from the commit that added the SQL file, the journal truncated to the preceding entries, and `drizzle-kit generate --name <original tag>` run; only the snapshot JSON was kept. The committed SQL files and journal are byte-identical to main (verified — deployed DBs track migrations by content, so they must not change). The snapshot id/prevId chain is intact 0002→…→0007. Notes from the replay: 0003's generated SQL differs in form from the committed hand-written DROP+CREATE but produces the same table shape (verified column-by-column); 0004's committed file prepends a hand-written DELETE dedupe; 0005/0006 were added in one commit so an intermediate schema was built for 0005; 0005–0007 generated byte-identical SQL. **Acceptance:** `db:generate` now reports "No schema changes" (clean no-op); fresh-DB migrate applies all migrations. **Commit 2:** with generate working again, the dead `annotations` table (no repository method, route, or test — re-verified) is dropped via a proper generated `0008_drop_annotations` migration. Tests: 56 files / 311 passing, typecheck clean, fresh-DB migrate verified before and after the drop.
Migrations 0003-0007 were committed without their meta snapshots, so
drizzle-kit generate diffed the current schema against the stale 0002
snapshot and proposed spurious changes.

Each snapshot was reconstructed by checking out schema.ts at the commit
that introduced the corresponding migration (0003: 2b6fcc9, 0004: ed01e9d,
0005/0006: d066388 split into intermediate states since both were added
in one commit, 0007: ad7c60f), truncating the journal to the preceding
entries, and re-running drizzle-kit generate with the original tag. The
generated SQL was verified semantically identical to the committed files
(0005-0007 byte-identical modulo trailing newline; 0003/0004 differ only
by their hand-written DROP/recreate and DELETE-dedupe edits, with the
same resulting schema). Only the snapshot JSONs are kept; the committed
SQL files and _journal.json are byte-identical to before.

Verified: drizzle-kit generate is now a clean no-op against the current
schema, migrations apply cleanly to a fresh database, and pnpm test
(311 tests) and pnpm typecheck pass.
No repository method, route, or test references the annotations table
(verified via project-wide grep; the only match was the schema
definition itself). Removed it from schema.ts and generated migration
0008_drop_annotations with drizzle-kit.

Verified: fresh-DB migration succeeds, drizzle-kit generate is a no-op,
pnpm test (311 tests) and pnpm typecheck pass.
pregno force-pushed fix/drizzle-meta-snapshots from 7ef3dfc16b to 6dc344a152 2026-06-13 01:30:02 +02:00 Compare
pregno merged commit 7b92bea74d into main 2026-06-13 01:30:35 +02:00
pregno deleted branch fix/drizzle-meta-snapshots 2026-06-13 01:30:35 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pregno/polymarket-screener!9
No description provided.