Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detected resolved migration not applied to database on flyway

We are using flyway to manage database schema version and we are facing a problem. Since we work as a team and use git as our source code management, there would be some cases that different people update database schema on their own local repo. If that happens, we will get

Detected resolved migration not applied to database: 2016.03.17.16.46"

The time "2016.03.17.16.46" was added by another person and I have already applied some timestamp later than that time. If that happens, we have to clean all database tables and create them again. We have tried to set false on validateOnMigrate and did flywayClean, but nothing help. Is there another way to change that?

like image 568
Joey Yi Zhao Avatar asked Mar 18 '16 06:03

Joey Yi Zhao


People also ask

How does Flyway connect to database?

In order to connect with your database, Flyway needs the appropriate JDBC driver to be available in its drivers directory. To see if Flyway ships with the JDBC driver for your database, visit the Driver section of the documentation page for your database. For example, here is the Oracle Drivers section.

Where do Flyway migrations go?

By default Flyway will look for migrations on the classpath under db/migration, which on a Maven project means src/main/resources/db/migration. You can however also use a location starting with the filesystem: prefix that can be anywhere on your disk.


1 Answers

The migration option outOfOrder is your friend here. Set it to true to allow inserting those migrations after the fact.

On the command line, run:

flyway -outOfOrder=true migrate 

Or if you use the Maven plugin:

mvn -Dflyway.outOfOrder=true flyway:migrate 
like image 57
Axel Fontaine Avatar answered Sep 21 '22 02:09

Axel Fontaine