在将Flyway从5.1.4升级到5.2.4之后,由于在调用 Flyway.migrate
时进行了迁移类型验证,因此出现了FlywayException异常:Migration type mismatch for migration eu.example.test.db.migration.repeatable.R__Fill_Event_Type_Table
-> Applied to database : SPRING_JDBC
-> Resolved locally : JDBC | (Main.java:273)
org.flywaydb.core.api.FlywayException: Validate failed: Migration type mismatch for migration eu.example.test.db.migration.repeatable.R__Fill_Event_Type_Table
-> Applied to database : SPRING_JDBC
-> Resolved locally : JDBC
at org.flywaydb.core.Flyway.doValidate(Flyway.java:1482)
at org.flywaydb.core.Flyway.access$100(Flyway.java:85)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1364)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1356)
at org.flywaydb.core.Flyway.execute(Flyway.java:1711)
at org.flywaydb.core.Flyway.migrate(Flyway.java:1356)
我已修复了基于Java的迁移中所有已弃用的警告,并迁移了旧的SpringJdbcMigration
迁移类以扩展自己的JdbcBaseJavaMigration
:
public abstract class JdbcBaseJavaMigration extends BaseJavaMigration {
@Override
public void migrate(Context context) throws Exception {
migrate(new JdbcTemplate(new SingleConnectionDataSource(context.getConnection(), true)));
}
/**
* Migrate with a {@link JdbcTemplate} (redirect from {@link #migrate(Context)}).
* @param jdbcTemplate The {@link JdbcTemplate}.
* @throws Exception when the migration failed.
*/
public abstract void migrate(JdbcTemplate jdbcTemplate) throws Exception;
@Override
public boolean isUndo() {
return false;
}
}
启动我的应用程序后,所有类型为 SPRING_JDBC 的旧迁移都将更改为类型 JDBC (我认为这是在 Flyway.repair 调用中发生的) )接受
可重复的迁移。包eu.example.test.db.migration.repeatable
中所有可重复的表在 flyway_schema_history 表中的类型仍为 SPRING_JDBC
并导致验证错误。
有人知道我在做什么错吗?谢谢你。
编辑:根据enter link description here,此问题不会在5.2.x中修复。