【发布时间】:2018-12-23 02:37:19
【问题描述】:
我正在尝试使用 Flyway 5.0.7 设置两个不同的数据库,用于开发的 MySQL 和用于测试的 H2。我已经在各自的文件中配置了两个数据库。
对于开发,src/main/resource/application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/moment
spring.datasource.username=root
spring.datasource.password=root
flyway.locations=db/migration,db/specific/mysql
对于测试,src/test/resource/application.properties
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
spring.datasource.username=sa
spring.datasource.password=sa
flyway.locations=db/migration,db/specific/h2
下面是 Flyway 迁移文件的文件夹结构
在这种情况下,Flyway 无法在 specific 文件夹下找到迁移文件,并在为 table not found 应用 V1.1__Insert_Records.sql 时引发错误。
如果我将specific 文件夹移动到db/migration 中,我会收到相同版本的重复文件的错误。
我应该如何为多个数据库配置迁移文件以使用 Flyway?
【问题讨论】:
-
你使用的是spring boot 2.x吗?如果是这样,下面的答案有帮助吗?如果没有,您使用的是什么版本?
标签: spring-boot database-migration flyway