ci: guard against editing applied migrations and version reuse#574
Merged
Conversation
An agent PR reworded the comment in an already-applied Flyway migration
(assistant-api V12). Flyway checksums the whole file, so the edit flipped the
checksum and crashlooped assistant-api on the next boot. Nothing in CI caught
it before merge.
check-migrations.sh enforces two invariants on every PR:
- immutability: a migration present on the base branch may not be modified,
renamed, or deleted (label allow-migration-change downgrades this to a
warning for a reviewed correction);
- versioning: per service, versions are unique and each newly added
migration's version exceeds the highest already on the base branch.
knowledge-api splits versions across migration/ and migration-pg/; both trees
share one per-service version namespace, which the script accounts for. The
workflow runs unconditionally so it is safe to require as a status check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
An agent PR reworded the leading comment of an already-applied Flyway migration (
assistant-apiV12). Flyway checksums the entire file, so the reword flipped the checksum andvalidatehard-failed on boot —assistant-apiandassistant-api-wscrashlooped in production. Nothing in CI flagged it before merge. (The repair is #573.)What
infra/scripts/check-migrations.sh, run by a newMigration Guardworkflow on every PR, enforces two invariants:allow-migration-changelabel to downgrade this to a warning (used for the V12 restore in assistant-api: restore V12 migration to its applied content (fix Flyway checksum crashloop) #573).knowledge-apisplits versions acrossdb/migration/anddb/migration-pg/; both trees share one per-service version namespace, which the script accounts for.The workflow runs unconditionally (a PR touching no migrations still reports a green check in seconds), so it is safe to mark as a required status check — recommended, since that is what turns this from advisory into a real gate.
Verified
Locally: passes on a clean tree, fails with a clear message on a committed edit to an existing migration (the exact V12 failure mode), and the
allow-migration-changeoverride downgrades that to a warning.