很多网上关于Flyway整合springboot的说明并不明确
Flyway在6.0之前是有兼容的,在6.0之后是没有做兼容的,小编的版本是6.0+
报错如下:
Caused by: org.flywaydb.core.api.FlywayException: Validate failed: Detected failed migration to version 2.3.0.2020081801 (role rights)
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)
at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:65)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1830)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1767)
...
- 原因一:版本过高,表名变成了flyway_schema_history
解决:
flyway:
baseline-on-migrate: true
encoding: utf-8 #字符编码
out-of-order: true #是否允许无序的迁移
enabled: true #是否启用flyway
table: schema_version
validate-on-migrate: true
官方建议是配置table:schema_version
- 原因二:
sql语句执行错误,其实就是你的脚本有问题,找到schema_version 删除出错的脚本的记录,然后修改脚本再重新执行即可
版权声明:本文为weixin_43409994原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。