Skip to content
Latchkey

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".

Spring Boot
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    : 987654321

Common 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

  1. Revert the edited migration to its original content.
  2. Put the change in a new higher-version migration file.
  3. Re-run so validation passes against unchanged history.
src/main/resources/db/migration
-- 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.

Terminal
./gradlew flywayRepair

How 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.

Frequently asked questions

What causes ""Validate failed: Migration checksum mismatch""?
Someone changed the body of an already-applied versioned migration, so its resolved checksum no longer matches the one recorded in flyway_schema_history.
How do I fix "Validate failed: Migration checksum mismatch"?
Never edit applied migrations; add a new one

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card