Flyway - 迁移到特定版本
Flyway - Migrate to specific version
有没有办法告诉flyway只迁移到特定版本?例如我有 4 个版本,例如V1
、V2
、V3
和 V4
脚本,我只想迁移到 V3
而不是 v4.
迁移任务有一个“目标”属性,可让您指定。
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.
命令行文档:https://flywaydb.org/documentation/usage/commandline/migrate
maven 示例
mvn -Dflyway.target=5.1 flyway:migrate
如果您使用 flyway 命令行并且只想迁移到 V3,您应该这样做:
flyway -configFiles=myconf.conf -target=3 migrate
如果您想测试迁移,可以使用 Java API:
@Test
public 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
}
有没有办法告诉flyway只迁移到特定版本?例如我有 4 个版本,例如V1
、V2
、V3
和 V4
脚本,我只想迁移到 V3
而不是 v4.
迁移任务有一个“目标”属性,可让您指定。
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.
命令行文档:https://flywaydb.org/documentation/usage/commandline/migrate
maven 示例
mvn -Dflyway.target=5.1 flyway:migrate
如果您使用 flyway 命令行并且只想迁移到 V3,您应该这样做:
flyway -configFiles=myconf.conf -target=3 migrate
如果您想测试迁移,可以使用 Java API:
@Test
public 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
}