fix(migrations): resolve version collision on 20260720120000#182
Conversation
#141 (raw-code baseline index) and #177 (journal normalization) both landed a 20260720120000 migration; sqlx keys _sqlx_migrations by version, so applying both fails with a duplicate-key violation — and the partial run records the INDEX migration's checksum at that version. Keep the index file at 20260720120000 (matching the recorded ledger row) and move the journal normalization to 20260720122000, updating the two include_str! test paths. Fresh databases apply index -> staging -> normalize in order; databases that hit the partial run resume cleanly at 121000. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9RTnbCyhqEUSPc7xCK76p
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Renaming this journal-normalization migration to 20260720122000 makes the compiled migrator expect the raw-code-index checksum at version 20260720120000. Any database that already applied this normalization migration while it still occupied 20260720120000—for example a staging/dev DB migrated after that branch landed but before the raw-code index, or a duplicate-version run that processed normalization first—will now hit the migration/healthcheck checksum-mismatch fail-closed path before 20260720122000 can run, even though its schema already contains resolver_profile_authority_journal_entries. Please add an explicit ledger/schema repair path or operator instruction for that alternate applied ledger; this fix only handles databases whose 20260720120000 row is the raw-code index.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Two same-day PRs (#141's raw-code baseline index and #177's journal normalization, authored in parallel branches) both landed a migration versioned
20260720120000. sqlx keys_sqlx_migrationsby version, so a fresh migrate run applies one and fails on the second with a duplicate-key violation — this breaks every fresh-database CI run on main and blocked the live v9 deploy's migrate step (observed live: the partial run applied and recorded the index migration at that version, then aborted).Fix keeps the ledger-compatible assignment: the index file stays at
20260720120000(matching the checksum already recorded on the deploy database), the journal normalization moves to20260720122000(after the121000staging migration; no inter-dependency — the staging table is standalone and the normalization reads only its own header table). The twoinclude_str!test paths that pin the normalization filename are updated; the index is referenced everywhere by NAME, which is unchanged. Content of all three migrations is byte-identical to main — this is purely a version/filename move.Validation: fresh databases apply index → staging → normalize in order (CI's DB-backed suites exercise exactly this); the partially-migrated deploy database resumes cleanly at
121000with no checksum mismatch.Process note for the retro: both #141 and #179 passed their full review gates green because each branch's migration set was internally consistent — the collision only exists in the merged union, and no gate ran a fresh migrate on post-merge main before deploy. Cheap guard candidate: a CI step (or pre-merge check) asserting migration version uniqueness across the tree, filed as #183.
🤖 Generated with Claude Code
https://claude.ai/code/session_01C9RTnbCyhqEUSPc7xCK76p