Spring Boot 在r2dbc之前运行liquibase

dauxcl2d  于 5个月前  发布在  Spring
关注(0)|答案(1)|浏览(62)

我知道我可以一起运行R2DBC and liquibase,但我想知道如何确保Liquibase首先运行?
r2 dbc-mysql驱动程序不支持创建数据库,如果数据库丢失,那么它将在启动时失败,除非数据库存在

kgqe7b3p

kgqe7b3p1#

首先,Sping Boot /R2 dbc在classpath中支持schema.sqldata.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中,并带有版本号。

+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

相关问题