-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Description
When Flyway migrations are already applied and marked successful in flyway_schema_history, subsequent changes to migration files (or their contents) alter the file checksum and cause Flyway validation errors on service startup. This ticket requests a change so that migrations which have been applied successfully are skipped from causing checksum validation failures when the file content changes locally. The change will allow developer workflows (editing local migration files for non-production development) and deployments to avoid failing due to altered checksums for already-applied migrations.
Goals
- Prevent Flyway from failing startup when a previously applied migration file's checksum differs from the recorded checksum.
- Document the change and test instructions for developers and DevOps.
Expected Outcome
- Flyway validation should ignore checksum differences for migrations that are already applied and successful, when configured to do so, so the service does not fail on startup because of local file edits that change checksums.
- The solution should be configurable (property/flag) and clearly documented so teams can enable it only in non-production contexts or developer environments.
Acceptance Criteria
- Given a migration row in
flyway_schema_historywithsuccess = true, changing the corresponding migration file checksum locally and restarting the service should not cause Flyway validation failures when the new configuration flag is enabled. - The behaviour must be toggleable via configuration (e.g., Spring profile, environment variable or Flyway property) and documented.
- Production deployments (by default) must keep strict validation enabled.
Implementation Details
Proposal
- Add a configurable Flyway validation rule that ignores migrations matching an "already-applied" pattern. Investigate using Flyway's
ignoreMigrationPatterns(or equivalent) to skip checksum validation for applied migrations — see Redgate blog reference above. - Expose a Spring Boot property (e.g.
amrit.flyway.ignore-applied-migration-checksum=true/false) that, when enabled in non-production profiles, configures Flyway to ignore checksum mismatches for migrations that are already applied. - Ensure the property is false by default. Wire the property to be enabled in local / developer profiles only (e.g.,
application-local.yml, or via an env varAMRIT_FLYWAY_IGNORE_APPLIED=trueused in developer docker-compose).
Tech notes
- Repo: https://github.com/PSMRI/AMRIT-DB
- Tech stack: Java, Spring Boot, Flyway, Docker (local dev)
- Candidate Flyway mechanisms:
ignoreMigrationPatterns, customValidationStrategy, or configuringflyway.validateMigrationNaming/flyway.baselineOnMigratedepending on Flyway version. - Make sure changes only affect validation behavior, not the recorded
flyway_schema_historyentries.
Mockups/Wireframes
Not applicable.
How to Test (manual steps)
- Run AMRIT-DB locally (or dev environment) so Flyway applies all migrations successfully.
- Confirm a migration row is present in
flyway_schema_historywithsuccess = trueand note thechecksumvalue. - Modify the checksum value in the
flyway_schema_historytable (to simulate a changed file checksum) OR change the migration file contents locally which would alter checksum on next run. - Restart the AMRIT-DB service and observe that, without the change, Flyway reports checksum validation errors and service startup fails.
- Enable the new configuration (e.g., set
AMRIT_FLYWAY_IGNORE_APPLIED=trueor use thelocalSpring profile) and restart the service. - Confirm the service starts successfully and Flyway does not fail on the checksum mismatch for the already-applied migration.
Repro steps summary: Run AMRIT-DB, apply migrations, change checksum in flyway_schema_history table, rerun service and observe checksum error. After enabling the new config, the error should not occur.
Tech Skills Needed
- Database
- MySQL
- Java
- Spring Boot
- CI/CD / DevOps
Organizational Mentor
Complexity
- Medium
Category
- Backend
- Database
- CI/CD
- Maintenance