I want my application to use r2dbc drive when running and jdbc to handle the database with Liquibase. I have this as a reference. It is possible by adding the correct configuration inside application.properties
and build.gradle.kts
to achieve that. Update and everything is working but not automatically. Do you have any suggestions?Spring's reference
You have two options to use db migrations like Liquibase in a R2bc application.
Till now Liquibase did not support R2dbc, and by default R2dbc and Jdbc can not be activated in a single Spring boot application. In a reactive Spring Boot application, although you added a Jdbc starter, it is not activated by default.
But you can setup liquibase in a R2dbc application, and configure Liquibase Maven/Gradle plugin to migrate the database manually by Gradle tasks/Maven goals. See my example: liquibase-maven-r2dbc, make sure the db is running, and execute mvn liquibase:update
in the project root.
See the official guide of Liquibase Maven Plugin, https://docs.liquibase.com/tools-integrations/maven/workflows/using-liquibase-maven-plugin-and-springboot.html
Both Liquibase/flyway provides standalone CLI tools, if your database migration scripts is outside of a project(or as a specific project just includes the scripts), and is maintained by dbamin or via CI/CD pipeline. The CLI is a good option. Thus it separates scripts from your main project.
Use R2dbc Migrate directly, it is similar to Flyway but working with 2rdbc. See my example: r2dbc-migrate.
Update: In the latest Spring Boot 3.x, it seems it is possible to setup Liquibase/flyway in a WebFlux project, you have to add jdbc driver and setup connection config(DO NOT use datasource). But I would like to use R2dbcMigrate which is designated to Reactive stack.