Flyway - Migrate to specific version
The migrate Task has a "target" attribute which lets you specify that.
target - The target version up to which Flyway should considermigrations. Migrations with a higher version number will be ignored.The special value current designates the current version of theschema.
Doc for CommandLine: https://flywaydb.org/documentation/usage/commandline/migrate
Example for maven
mvn -Dflyway.target=5.1 flyway:migrate
If you would like to test you migrations, you can use Java API:
@Testpublic void test() { final FluentConfiguration fluentConfiguration = Flyway.configure() .dataSource(dataSource); fluentConfiguration.target("3") // stable version .load() .migrate(); // ... your SQL injection queries fluentConfiguration .target("latest") // remaining versions you need to test .load() .migrate(); // ... your SQL select checks}