Flyway - Migrate to specific version

14,236

Solution 1

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 

Solution 2

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
Share:
14,236

Related videos on Youtube

CrazyCoder
Author by

CrazyCoder

Updated on September 15, 2022

Comments

  • CrazyCoder
    CrazyCoder over 1 year

    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.

  • naXa stands with Ukraine
    naXa stands with Ukraine over 6 years
    It would be nice if you add usage examples to your answer.
  • DmitrySandalov
    DmitrySandalov almost 6 years
    mvn -Dflyway.target=5.1 flyway:migrate
  • Jorge Guillermo Negrete
    Jorge Guillermo Negrete over 2 years
    The link doesn't work anymore, new one: flywaydb.org/documentation/usage/commandline/migrate