I'm using flyway with gradle, I've run one of the migrations manually inside the database console, I want to run flyway, but tell it to ignore one specific migration version in between all the others.
Can this be done?
Asked
Active
Viewed 3.1k times
3 Answers
21
You would have to hack it a bit to get it to work, so I don't recommend this approach, but it would work in a pinch.
I've only tested this with Maven, but I'm pretty sure it'd work with Gradle too.
Migrate up until the version before the one you applied manually
# Assuming you applied 01.002 manually $ mvn flyway:migrate -Dflyway.target=01.001
Insert a row for the script you applied
-- Make sure these vals closely replicate those from other rows insert into schema_version( installed_rank, version, description, type, script, checksum, installed_by, installed_on, execution_time, success) values ( 2, '01.002', 'static_data', 'SQL', 'V01/V01.002__static_data.sql', null, 'username', current_timestamp, 0, true );
Repair the
schema_version
checksum$ mvn flyway:repair
Apply the other migrations
$ mvn flyway:migrate -Dflyway.validateOnMigrate=false -Dflyway.outOfOrder=true
The two -D
properties there may not be necessary, depending on whether you got the insert
correct or not. Flyway may disagree with your script description, for example, even if the checksum is now correct.

pards
- 1,098
- 15
- 20
-
Sometime no need for inserting crafted `insert` (for example if your upgrade script failed on adding existing column or dropping already removed table). Just allow for Flyway to fail and fix latest line by setting `success = 1`. You can make safe failure with garbage at the beginning of update script (that prevents further possibly dangerous actions). Just remove garbage before `flyway:repair` – gavenkoa Nov 19 '17 at 14:23
7
Not Recommended, but if you still want to:
- Run flywayMigrate, let the migration fail.
- Manually, update the flyway meta table (success column) for that specific version of migration.
- Run flywayMigrate again.
- Done, flyway will now start with the next version of migration.

fat
- 6,435
- 5
- 44
- 70

Sagar Ahuja
- 637
- 10
- 10
1
As of version 7, you can add it directly to your Maven or Grade file
Gradle - Skip
flyway {
skipExecutingMigrations = true
}
Maven - Skip
<configuration>
<skipExecutingMigrations>true</skipExecutingMigrations>
</configuration>
Gradle - Cherry Pick
flyway {
cherryPick = '2.0'
}
Maven - Cherry Pick
<configuration>
<cherryPick>2.0</cherryPick>
</configuration>

Justin Nimmo
- 125
- 12
-
2Please note that the parameter "skipExecutingMigrations" is a Teams edition feature. That means you must pay to use this feature. – johnlinp Feb 11 '22 at 02:58
-
It works only in paid edition. In my opinion, Liquibase is a much better solution than Flyway. You do not have to pay for basic features. – Krzysztof Feb 11 '23 at 11:02
-
-
I am not shooting anyone. The person who asked did not specify Flyway version, so if a solution requires paid version, the answer should mention this requirement. – Krzysztof Mar 01 '23 at 09:53