Spring Boot Flyway "Migration ... failed" / "Validate failed" in CI
Spring Boot runs Flyway on startup. "Validate failed" means an already-applied migration was changed (its checksum no longer matches history); "Migration ... failed" means a versioned script threw against the CI database.
What this error means
Startup or @SpringBootTest fails with "FlywayValidateException: Validate failed: Migrations have failed validation ... checksum mismatch" or "Migration V2__x.sql failed".
org.flywaydb.core.api.exception.FlywayValidateException: Validate failed: Migrations
have failed validation
Migration checksum mismatch for migration version 2
-> Applied to database : 123456789
-> Resolved locally : 987654321Common causes
An applied migration file was edited
Someone changed the body of an already-applied versioned migration, so its resolved checksum no longer matches the one recorded in flyway_schema_history.
A migration statement fails on the CI DB
The SQL runs against a fresh CI database whose engine or state differs, so a statement (a missing table, a syntax quirk) errors.
How to fix it
Never edit applied migrations; add a new one
- Revert the edited migration to its original content.
- Put the change in a new higher-version migration file.
- Re-run so validation passes against unchanged history.
-- add V3__adjust_orders.sql instead of editing V2
ALTER TABLE orders ADD COLUMN status varchar(32);Repair history only when intentional
If the change was deliberate and safe, run flyway repair to realign checksums, but prefer new migrations.
./gradlew flywayRepairHow to prevent it
- Treat applied migrations as immutable; always add a new version.
- Run migrations against a fresh CI DB so failures surface early.
- Review migration diffs in PRs to catch edits to applied files.