I'm using flyway with gradle, I've ran 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 ?
问题:
回答1:
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.
回答2:
Not Recommended But if you still want to :
1) Run flywayMigrate, let the migration fail.
2) Manually, update the flyway meta table(success column) for that specific version of migration.
3) Run flywayMigrate again.
4) Done, flyway will now start with the next version of migration.