ci: add migration-immutability guard for sqlx checksum drift #301

Merged
vas2000-work merged 1 commit from feat/BUNYIP-293-migration-immutability-guard into main 2026-07-01 07:13:29 +02:00
Member

sqlx checksums every applied migration in _sqlx_migrations and re-verifies it on every startup, so modifying, renaming, or deleting a migration already applied to a database makes that database refuse to boot ("migration was previously applied but has been modified"). This took down the mokosh-server v0.4.0 deploy on nc-01 (DEV-395) and has bitten this repo before (BUNYIP-79 edited 11 applied migrations in place; see scripts/reconcile-sqlx-checksums.md). Nothing in CI caught the edit.

Add scripts/check-migration-immutability.sh (sibling to the version-number gate): it diffs bunyip-api/migrations against the merge-base with origin/main with --diff-filter=MRD and fails (exit 1, naming the offending files and telling the author to add a new migration) if any committed migration was modified, renamed, or deleted. Adding new migration files passes. It fails loud (exit 2) if the diff itself cannot run, so a missing base ref or shallow clone never silently reads as "nothing changed".

Wire it into .forgejo/workflows/check.yml as a step and set fetch-depth: 0 on the checkout so the merge-base with origin/main is available. Document migration immutability in CLAUDE.md.

#BUNYIP-293

sqlx checksums every applied migration in _sqlx_migrations and re-verifies it on every startup, so modifying, renaming, or deleting a migration already applied to a database makes that database refuse to boot ("migration <version> was previously applied but has been modified"). This took down the mokosh-server v0.4.0 deploy on nc-01 (DEV-395) and has bitten this repo before (BUNYIP-79 edited 11 applied migrations in place; see scripts/reconcile-sqlx-checksums.md). Nothing in CI caught the edit. Add scripts/check-migration-immutability.sh (sibling to the version-number gate): it diffs bunyip-api/migrations against the merge-base with origin/main with --diff-filter=MRD and fails (exit 1, naming the offending files and telling the author to add a new migration) if any committed migration was modified, renamed, or deleted. Adding new migration files passes. It fails loud (exit 2) if the diff itself cannot run, so a missing base ref or shallow clone never silently reads as "nothing changed". Wire it into .forgejo/workflows/check.yml as a step and set fetch-depth: 0 on the checkout so the merge-base with origin/main is available. Document migration immutability in CLAUDE.md. #BUNYIP-293
ci: add migration-immutability guard for sqlx checksum drift
All checks were successful
E2E / Playwright against deployment (pull_request) Successful in 34s
Check / fmt + clippy + build + tests (pull_request) Successful in 30m31s
763afdfb7d
sqlx checksums every applied migration in _sqlx_migrations and re-verifies it on every startup, so modifying, renaming, or deleting a migration already applied to a database makes that database refuse to boot ("migration <version> was previously applied but has been modified"). This took down the mokosh-server v0.4.0 deploy on nc-01 (DEV-395) and has bitten this repo before (BUNYIP-79 edited 11 applied migrations in place; see scripts/reconcile-sqlx-checksums.md). Nothing in CI caught the edit.

Add scripts/check-migration-immutability.sh (sibling to the version-number gate): it diffs bunyip-api/migrations against the merge-base with origin/main with --diff-filter=MRD and fails (exit 1, naming the offending files and telling the author to add a new migration) if any committed migration was modified, renamed, or deleted. Adding new migration files passes. It fails loud (exit 2) if the diff itself cannot run, so a missing base ref or shallow clone never silently reads as "nothing changed".

Wire it into .forgejo/workflows/check.yml as a step and set fetch-depth: 0 on the checkout so the merge-base with origin/main is available. Document migration immutability in CLAUDE.md.

#BUNYIP-293
vas2000-work force-pushed feat/BUNYIP-293-migration-immutability-guard from 763afdfb7d
All checks were successful
E2E / Playwright against deployment (pull_request) Successful in 34s
Check / fmt + clippy + build + tests (pull_request) Successful in 30m31s
to ee6b204769
All checks were successful
E2E / Playwright against deployment (pull_request) Successful in 23s
Check / fmt + clippy + build + tests (pull_request) Successful in 7m16s
Create release / Create release from merged PR (pull_request) Has been skipped
2026-07-01 06:55:06 +02:00
Compare
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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
psa-systems/bunyip!301
No description provided.