如何从 Flyway 迁移名称中删除前缀?
How to remove prefix from Flyway migration name?
默认情况下,Flyway 在文件夹 db/migration
中搜索以“V”开头的迁移,例如:
V1_1_0__init_schema.sql
但是,我的迁移具有以下命名模式(而且我无法更改迁移名称):
20210902193819451__init_schema.sql
如何从 Flyway 的默认行为中删除字母“V”,以便找到我的迁移?
我已经尝试在我的配置文件中设置以下 属性:
spring.flyway.sql-migration-prefix: ""
,但这不起作用,我收到以下错误:
Invocation of init method failed; nested exception is
org.flywaydb.core.api.exception.FlywayValidateException: Validate
failed: Migrations have failed validation
在这种情况下,Flyway 是一个 Spring 托管 bean。您的配置应该是 spring.flyway.sql-migration-prefix=V
所描述的 here。
注意,因为数据库迁移意味着 versioning, undo, and repeatable 迁移具有不同的前缀。您还应该注意,实体验证可能来自 Flyway(来自 table flyway_schema_history
),它检查您脚本的校验和,以及 Hibernate,它检查您的 @Entity
模型。
我解决了将以下配置添加到我的 application.yml
文件中的问题:
spring.flyway.sql-migration-prefix: "20"
spring.flyway.sql-migration-separator: "_"
我没有删除前缀,而是简单地替换了它。
默认情况下,Flyway 在文件夹 db/migration
中搜索以“V”开头的迁移,例如:
V1_1_0__init_schema.sql
但是,我的迁移具有以下命名模式(而且我无法更改迁移名称):
20210902193819451__init_schema.sql
如何从 Flyway 的默认行为中删除字母“V”,以便找到我的迁移?
我已经尝试在我的配置文件中设置以下 属性:
spring.flyway.sql-migration-prefix: ""
,但这不起作用,我收到以下错误:
Invocation of init method failed; nested exception is org.flywaydb.core.api.exception.FlywayValidateException: Validate failed: Migrations have failed validation
在这种情况下,Flyway 是一个 Spring 托管 bean。您的配置应该是 spring.flyway.sql-migration-prefix=V
所描述的 here。
注意,因为数据库迁移意味着 versioning, undo, and repeatable 迁移具有不同的前缀。您还应该注意,实体验证可能来自 Flyway(来自 table flyway_schema_history
),它检查您脚本的校验和,以及 Hibernate,它检查您的 @Entity
模型。
我解决了将以下配置添加到我的 application.yml
文件中的问题:
spring.flyway.sql-migration-prefix: "20"
spring.flyway.sql-migration-separator: "_"
我没有删除前缀,而是简单地替换了它。