Migration Checksums: What They Mean and How to Fix a Mismatch
A migration checksum is a value some tools store to detect whether a migration file has changed since it was applied. Flyway records a CRC32 checksum for SQL migrations and compares it with the current file during `validate`. This detects file changes; it does not prove that the live schema matches the script or authenticate who changed it. When validation reports a mismatch, first establish what changed and compare the schema history and actual database state across environments. For Flyway, treat versioned migrations already applied downstream as immutable and make corrections in a new migration. [Flyway: Validate](https://documentation.red-gate.com/flyway/reference/commands/validate) [Flyway: Versioned migrations](https://documentation.red-gate.com/fd/versioned-migrations-273973333.html) [NIST: CRC](https://csrc.nist.gov/glossary/term/cyclic_redundancy_check)
Migration Checksums: What They Mean and How to Fix a Mismatch
A migration checksum is a value some tools store to detect whether a migration file has changed since it was applied. Flyway records a CRC32 checksum for SQL migrations and compares it with the current file during validate. This detects file changes; it does not prove that the live schema matches the script or authenticate who changed it. When validation reports a mismatch, first establish what changed and compare the schema history and actual database state across environments. For Flyway, treat versioned migrations already applied downstream as immutable and make corrections in a new migration. Flyway: Validate Flyway: Versioned migrations NIST: CRC
What does the checksum compare?
Migration tools track executable files in source control and a record of what ran in each database. Flyway's schema history records applied versions, outcomes, and checksums. validate compares available migrations with that history and can report checksum, name, or type differences, as well as missing or unapplied versions. For Flyway SQL migrations the checksum is CRC32. It is a comparison value for the migration file, not a replay that checks whether the SQL achieved the intended result. Flyway: Validate Flyway schema history
For example, suppose V12__add_status.sql has already run in one database. A developer later appends a column change to that same file. The applied database records the old checksum, while an unapplied environment may run the edited file. One version number now represents different work across environments. The checksum exposes the edit; it does not compare or repair live database objects.
What does it not prove?
CRC detects accidental changes; it is not a cryptographic hash. NIST describes it as a non-cryptographic integrity mechanism. A matching Flyway CRC32 therefore does not establish authorship, rule out deliberate tampering, prove the migration is safe, or show that actual database objects match the script. Use validation alongside code review, version control, deployment records, schema comparison, and tested backups; do not treat it as a substitute for them. NIST: cyclic redundancy check
The word “checksum” is tool-specific. Flyway documents CRC32 for SQL migrations. Alembic's documented workflow orders scripts through revision and down_revision identifiers and records the current revision in alembic_version; these identifiers are not file-content checksums. An Alembic project that needs file-integrity verification must add a separate hash or signing process. Alembic: Tutorial
How should you investigate a Flyway mismatch?
**Pause deployment and preserve evidence.** Save the `validate` output, current migration file and commit history, schema-history records for each environment, and deployment logs. Do not run `repair` on production as the first response.
**Classify the cause.** Check whether an applied file was edited, deleted, or renamed; whether Flyway is reading the intended migration locations; and whether a failed run left partial DDL behind. Confirm which environments recorded success and inspect actual objects and data.
**For an accidental edit, restore the released file.** Recover the applied version from source control or the release artifact, then validate again. Restore missing or renamed files only after understanding deployment history and each database's state.
**Make needed changes forward.** If an already-applied schema needs more work, create a new versioned migration and deploy it consistently. Flyway recommends not changing versioned files after they have reached a permanent downstream environment. [Flyway: Versioned migrations](https://documentation.red-gate.com/fd/versioned-migrations-273973333.html)
**Consider `repair` only when history must intentionally be reconciled.** Flyway `repair` can remove failed entries, align recorded checksums/descriptions/types with available files, or mark missing migrations deleted. It does not reverse database DDL or rerun a script to make objects match. First verify actual database state agrees with the migration history you intend to record, and use the same migration `locations` as `migrate`. [Flyway: Repair](https://documentation.red-gate.com/fd/repair-277578892.html)
A quick decision table
| Observation | First action | Avoid |
|---|---|---|
| Only an applied Flyway file's checksum differs | Compare Git and release artifacts; restore the applied file | Updating history with repair before understanding the change |
| A file is missing but databases show it was applied | Check repository, package path, and release contents | Assuming it is obsolete and immediately marking it deleted |
| A failed migration left some objects behind | Inspect partial application and the database's DDL/transaction behavior; plan cleanup | Removing history while leaving objects unexplained |
| Environments have different schemas under the same revision | Compare backups, schemas, and environment histories | Assuming equal checksums mean equal live data |
A successful validation means a particular file-to-history comparison passed. It does not prove business data is correct or every environment has the same live schema. Keep released Flyway versioned files immutable and treat validation failures as evidence to investigate. Use repair only after understanding the cause and deliberately aligning history with reality.