Skip to content
Latchkey

Flyway "Validate failed: Migration checksum mismatch" in CI

Flyway recomputes a checksum for each migration file and compares it to the value stored when the migration was applied. A mismatch means an applied migration's file changed - Flyway blocks to protect history. This is deterministic.

What this error means

flyway migrate/validate fails with a checksum mismatch for a specific version, showing applied vs resolved checksums. It points at exactly which file was altered.

flyway
ERROR: Validate failed: Migrations have failed validation
Migration checksum mismatch for migration version 2.1
-> Applied to database : 1456789012
-> Resolved locally    : 9876543210

Common causes

An applied migration file was edited

The SQL (or whitespace, depending on config) of a versioned migration that already ran was changed, so its checksum no longer matches.

Line-ending or encoding change

Re-saving a file with different line endings or encoding can change the checksum even when the SQL looks identical.

How to fix it

Revert the applied migration

Restore the file so its checksum matches; add a new migration for further changes.

Terminal
git log -p -- sql/V2.1__add_orders.sql   # find what changed, then restore

Repair if the change is intentional

When the edit is deliberate and the database reflects it, flyway repair updates the stored checksums.

Terminal
flyway repair
flyway migrate

How to prevent it

  • Treat applied migrations as immutable; add new versions for further changes.
  • Normalize line endings via .gitattributes so checksums stay stable.
  • This is deterministic - retrying without reverting or repairing fails identically.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →