Is there a way to tell flyway to migrate only to specific version? For e.g. I have 4 versions e.g. V1
, V2
, V3
and V4
scripts and I want to migrate only to V3
but not to v4.
Flyway is an open-source database migration tool. It strongly favors simplicity and convention over configuration. It is based around just 7 basic commands: Migrate, Clean, Info, Validate, Undo, Baseline and Repair.
Migrate is the centerpiece of the Flyway workflow. It will scan the filesystem or your classpath for available migrations. It will compare them to the migrations that have been applied to the database. If any difference is found, it will migrate the database to close the gap.
Repeatable migrations have a description and a checksum, but no version. Instead of being run just once, they are (re-)applied every time their checksum changes. This is very useful for managing database objects whose definition can then simply be maintained in a single file in version control.
The migrate Task has a "target" attribute which lets you specify that.
target - The target version up to which Flyway should consider migrations. Migrations with a higher version number will be ignored. The special value current designates the current version of the schema.
Doc for CommandLine: https://flywaydb.org/documentation/usage/commandline/migrate
Example for maven
mvn -Dflyway.target=5.1 flyway:migrate
In case you use flyway command line and you want to migrate only to V3 you should do something like this:
flyway -configFiles=myconf.conf -target=3 migrate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With