Repository navigation
fix(db): repair stale migration snapshots after the #6606 merge - #6653
Conversation
The merge that brought the Live Activity migrations onto main (bdd0a95) resolved the `_journal.json` and `0255_snapshot.json` conflicts, but left `0256_snapshot.json` stale. It still recorded `repository_customizations`, which #6558 had dropped, so `drizzle generate` emitted a spurious `DROP TABLE "repository_customizations" CASCADE;` against a table that no longer exists. Also renumber the two Live Activity migrations so each tag prefix matches its journal idx, and rebuild the tail snapshots to match each migration state. The journal `when` values are unchanged, so already-applied migrations are not re-run. - 0255_snapshot.json: state after DROP repository_customizations - 0256_snapshot.json: state after ADD COLUMN superseded_at - 0257_snapshot.json: state after the partial unique index
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Reviewed the migration metadata repair. The two Verified the snapshot chain ( Files Reviewed (6 files)
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
Repairs the migration metadata left inconsistent by the merge that brought the Live Activity migrations onto main.
Problem
The merge
bdd0a95b8bresolved the_journal.jsonand0255_snapshot.jsonconflicts, but left0256_snapshot.jsonstale:0255_snapshot.jsoncorrectly recordsrepository_customizationsas dropped.0256_snapshot.jsonrecords it as present again, sodrizzle generateemits a spuriousDROP TABLE "repository_customizations" CASCADE;.0256_..., but no0257_snapshot.json.packages/db/src/schema.test.tsderives the snapshot path fromidx, so it reads a missing file.Change
0255_add_superseded_at_to_user_activity_tokens.sql→0256_...0256_user_activity_tokens_live_ios_activity_unique.sql→0257_...0255_snapshot.json: afterDROP repository_customizations0256_snapshot.json: afterADD COLUMN superseded_at0257_snapshot.json: after the partial unique indexwhenvalues are unchanged, so already-applied migrations are not re-run (the migrator recordshash+created_atonly).Verification
drizzle-kit check: no collisions.drizzle generatediff: 0 pending statements.pnpm --filter @kilocode/db test(DB-less): 7 suites, 32 tests pass.schema.test.tsassertion was reproduced without a database: the idx-derived0257_snapshot.jsonexists and yields 0 statements.Note
This edits generated migration metadata.
packages/db/AGENTS.mdnormally forbids that, but regeneration cannot reconstruct already-merged history without re-runningADD COLUMNon databases that already applied it.