Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flyway - Migrate to specific version

Is there a way to tell flyway to migrate only to specific version? For e.g. I have 4 versions e.g. V1, V2, V3and V4 scripts and I want to migrate only to V3 but not to v4.

like image 810
CrazyCoder Avatar asked Apr 13 '15 13:04

CrazyCoder


People also ask

Does Flyway migrate data?

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.

What does Flyway migrate do?

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.

What is repeatable migration in Flyway?

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.


2 Answers

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 
like image 199
Slettal Avatar answered Sep 22 '22 07:09

Slettal


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
like image 44
nicola Avatar answered Sep 21 '22 07:09

nicola