Skip to content

fix(migrations): resolve version collision on 20260720120000#182

Merged
tayy-i merged 1 commit into
mainfrom
fix/migration-version-collision
Jul 21, 2026
Merged

fix(migrations): resolve version collision on 20260720120000#182
tayy-i merged 1 commit into
mainfrom
fix/migration-version-collision

Conversation

@tayy-i

@tayy-i tayy-i commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

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_migrations by 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 to 20260720122000 (after the 121000 staging migration; no inter-dependency — the staging table is standalone and the normalization reads only its own header table). The two include_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 121000 with 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

#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
@tayy-i

tayy-i commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@tayy-i
tayy-i merged commit 7243615 into main Jul 21, 2026
10 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

CREATE TABLE public.resolver_profile_authority_journal_entries (

P2 Badge Add a repair path for the other 20260720120000 ledger

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants