Skip to content
Latchkey

Flyway "Detected resolved migration not applied" (Out of Order)

Flyway found a migration with a version lower than ones already applied, but it was never run. By default Flyway will not insert an out-of-order migration into history and fails validation. This is a versioning/ordering issue.

What this error means

flyway migrate/validate fails reporting a resolved migration that is not applied, naming a version below the current schema version. It happens when a branch adds a lower-numbered migration after higher ones merged.

flyway output
ERROR: Validate failed: Detected resolved migration not applied to
database: 2.3. To allow executing this migration, set -outOfOrder=true.

Common causes

A lower-version migration merged late

Two branches created migrations; the lower-numbered one merged after the higher-numbered one already ran, leaving a gap Flyway will not fill by default.

Versions assigned out of sequence

Manual version numbering produced a new migration below the current schema version, which Flyway treats as out of order.

How to fix it

Renumber the migration to the next version

The cleanest fix is to give the late migration a version above the current head so history stays linear.

Terminal
# rename V2.3__... to the next free version above current head
git mv sql/V2.3__add_index.sql sql/V2.5__add_index.sql

Allow out-of-order application deliberately

If you intend to support inserting older migrations, enable outOfOrder so Flyway applies the gap.

Terminal
flyway migrate -outOfOrder=true

How to prevent it

  • Assign migration versions in strict increasing order; renumber late ones.
  • Decide once whether outOfOrder is enabled and apply it everywhere.
  • Run flyway validate in CI to catch ordering gaps early.

Frequently asked questions

What causes ""resolved migration not applied""?
Two branches created migrations; the lower-numbered one merged after the higher-numbered one already ran, leaving a gap Flyway will not fill by default.
How do I fix "resolved migration not applied"?
The cleanest fix is to give the late migration a version above the current head so history stays linear.

Related guides

References

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