Skip to content

fix(db): keep migration versions unique - #49

Merged
haasonsaas merged 1 commit into
mainfrom
fix/corpus-migration-startup
Aug 4, 2026
Merged

fix(db): keep migration versions unique#49
haasonsaas merged 1 commit into
mainfrom
fix/corpus-migration-startup

Conversation

@haasonsaas

@haasonsaas haasonsaas commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Root cause\n\nProduction Corpus reached Cloud SQL after the deploy-repo egress fix, then failed at startup because the repository contains two migrations with version prefix 0010. SQLx stores that prefix as the primary key in the _sqlx_migrations table; the live database has version 10 (receipts and cleanup) applied, and the second 0010 (Merlin observations) caused the duplicate-key failure.\n\n## Fix\n\n- Rename 0010_merlin_observations.sql to 0012_merlin_observations.sql, preserving the already-applied version-10 checksum and allowing version 11 to apply before Merlin version 12.\n- Add a unit regression test that rejects duplicate numeric migration prefixes.\n\n## Verification\n\n- cargo fmt --all -- --check\n- cargo test -p corpus-core --lib (96 passed)\n- cargo test -p corpus-server --no-run\n- Live DB migration state inspected read-only; no values or secrets exposed.

@haasonsaas
haasonsaas merged commit c340b63 into main Aug 4, 2026
5 checks passed
@haasonsaas
haasonsaas deleted the fix/corpus-migration-startup branch August 4, 2026 20:03
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.

1 participant