升级到 Spring Boot 2.4.2 后,现有的 Flyway 迁移验证失败

时间:2021-01-22 12:39:29

标签: java spring spring-boot flyway

我刚刚将 Spring Boot 应用程序从 2.3.5.RELEASE 升级到 2.4.2。现在,当我尝试在现有数据库上启动我的应用程序时,Flyway 迁移失败并显示 Validate failed: Migrations have failed validation。没有详细信息或其他消息,只有这一条。通常 Flyway 会通知我校验和不匹配或其他问题,但在这种情况下什么都没有。

我是否错过了 Spring (Boot) 或 Flyway 中的一些向后不兼容的更改?如何修复我的迁移?

2 个答案:

答案 0 :(得分:1)

我在使用 spring Boot 2.4.2 和 Flyway 时遇到了类似的问题,并显示相同的错误消息“验证失败:迁移验证失败”,但没有提供更多详细信息。

发生这种情况是因为我的脚本版本号之间存在差距。 我必须在 flyway 配置中添加 ignoreMissingMigrations(true) 才能使其再次工作。

我不知道为什么这个flyway版本不再报告丢失的迁移脚本了...

答案 1 :(得分:0)

Flyway 7.1.0 附带 Spring Boot 2.4。但是,此版本的 Flyway 未正确记录验证异常 (https://flywaydb.org/documentation/learnmore/releaseNotes)。

我通过在 maven pom.xml 中添加以下代码临时管理这个依赖:

<dependencyManagement>
   <dependencies>
     <dependency>
       <groupId>org.flywaydb</groupId>
       <artifactId>flyway-core</artifactId>
       <version>7.2.1</version>
     </dependency>
   </dependencies>
</dependencyManagement>