Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flyway out of order migration

Imagine I have the following flyway migrations:

  • V1__create_table.sql
  • V2__create_table.sql
  • V4__create_table.sql

And these migrations have been applied to my database. Is there a possibility to add the following script:

  • V3__create_table.sql

And let flyway run this migration out of order without complaining?

like image 729
Titulum Avatar asked Feb 13 '20 11:02

Titulum


People also ask

What is out of order in Flyway?

Description. Allows migrations to be run “out of order”. If you already have versions 1.0 and 3.0 applied, and now a version 2.0 is found, it will be applied too instead of being ignored.

How do you skip Flyway migration?

The hotfix migration can be deployed with Flyway with skipExecutingMigrations=true . The schema history table will be updated with the new migration, but the script itself won't be executed again. skipExecutingMigrations can be used with with cherryPick to skip specific migrations.

Are Flyway migrations transactional?

Flyway runs each migration in a separate transaction. In case of failure this transaction is rolled back.

Does Flyway support rollbacks?

To execute the rollback, call the following flyway commands in sequence. This runs all undo scripts starting from the current release, version 129, back to version 123. This will run the repeatable migrations, bringing the programmable object versions back to the state they had been in version 123.


Video Answer


1 Answers

Flyway 2 has flyway.outOfOrder property which is by default false You would have to set it to true to run your missing migration, as per migrate docs:

Allows migrations to be run "out of order".

If you already have versions 1 and 3 applied, and now a version 2 is found, it will be applied too instead of being ignored.

like image 164
Karol Dowbecki Avatar answered Sep 23 '22 15:09

Karol Dowbecki