我知道我可以一起运行R2DBC and liquibase,但我想知道如何确保Liquibase首先运行?r2 dbc-mysql驱动程序不支持创建数据库,如果数据库丢失,那么它将在启动时失败,除非数据库存在
kgqe7b3p1#
首先,Sping Boot /R2 dbc在classpath中支持schema.sql和data.sql,以便在应用程序启动时初始化数据库。查看我的示例项目:https://github.com/hantsy/spring-r2dbc-sample/tree/master/boot/src/main/resources对于开发阶段的数据库迁移,如果您在项目中使用Spring WebFlux/R2 dbc,请尝试使用r2dbc-migrate。对于Sping Boot 项目,只需要将r2dbc-migrate-spring-boot-starter添加到您的项目deps中。R2 dbc Migrate更类似于Flyway,您可以简单地将迁移脚本放置到classpath db/migration中,并带有版本号。
schema.sql
data.sql
db/migration
+main +resouces +db +migration - V1__add_column_xxx.sql - V2__add_table_xxx.sql
+main
+resouces
+db
+migration
- V1__add_column_xxx.sql
- V2__add_table_xxx.sql
字符串查看我的示例项目:https://github.com/hantsy/spring-r2dbc-sample/tree/master/r2dbc-migrate/src/main/resources/db/migration
1条答案
按热度按时间kgqe7b3p1#
首先,Sping Boot /R2 dbc在classpath中支持
schema.sql
和data.sql
,以便在应用程序启动时初始化数据库。查看我的示例项目:https://github.com/hantsy/spring-r2dbc-sample/tree/master/boot/src/main/resources
对于开发阶段的数据库迁移,如果您在项目中使用Spring WebFlux/R2 dbc,请尝试使用r2dbc-migrate。
对于Sping Boot 项目,只需要将r2dbc-migrate-spring-boot-starter添加到您的项目deps中。
R2 dbc Migrate更类似于Flyway,您可以简单地将迁移脚本放置到classpath
db/migration
中,并带有版本号。字符串
查看我的示例项目:https://github.com/hantsy/spring-r2dbc-sample/tree/master/r2dbc-migrate/src/main/resources/db/migration