如何使用 mysql 和 h2 的常见 flyway 迁移文件
使用 h2 数据库作为测试用例,使用 mysql 数据库作为主数据库。 是否能够为两者保持单一的飞行路线迁移。
使用 springboot 框架。
application-mysql.properties 中:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.password=root
spring.datasource.url=jdbc:mysql://localhost:3306/shipment-planning?useSsl=true
spring.datasource.username=root
spring.flyway.default-schema=shipment-planning
spring.flyway.enabled=true
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=true
spring.flyway.locations = h2/db/migration
application-h2.properties
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MYSQL
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=sa
spring.flyway.enabled=true
spring.flyway.locations = h2/db/migration
在使用 Mysql.properties 运行时遇到的语法错误之一
“您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,在第 2 行的 'DATA TYPE TEXT' 附近使用正确的语法”