Liquibase R2DBC Spring Boot starter
This repository demonstrates how 2 implement Liquibase R2DBC Spring Boot starter to be used in reactive projects with MySQL, MariaDB, PostgreSQL, MS SQL Server, r2dbc-pool, r2dbc-proxy or H2 database. It's not pure reactive liquibase implementation as you might think, we are simply transforming R2DBC URL into liquibase compatible in a little spring-boot starter to apply liquibase migrations update automatically within application runner bean
Getting started
<dependency>
<groupId>io.github.daggerokgroupId>
<artifactId>liquibase-r2dbc-spring-boot-starterartifactId>
<version>2.0.5version>
dependency>
or
dependency("io.github.daggerok:liquibase-r2dbc-spring-boot-starter:2.0.5")
If you want to use *-SNAPSHOT
version, please make sure you have added snapshot maven repository like so
<repositories>
<repository>
<id>sonatype-nexus-snapshotsid>
<name>Sonatype OSS Snapshot Repositoryname>
<url>https://s01.oss.sonatype.org/content/repositories/snapshotsurl>
<snapshots><enabled>trueenabled>snapshots>
<releases><enabled>falseenabled>releases>
repository>
repositories>
or
repositories {
maven {
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
}
}
See: https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/daggerok/
Otherwise, use only released version. See: https://repo1.maven.org/maven2/io/github/daggerok/liquibase-r2dbc-spring-boot-starter/
Technology Stack
- Liquibase
- R2DBC
- Spring Boot
- Kotlin
- Junit Jupiter 5
- H2 (file, mem)
- MySQL
- MariaDB
- Postgresql
- MS SQL Server
- R2DBC (pool, proxy)
- Testcontainers
- Maven
Reference documentation
Checkout documentation for details
Developer guide for contributors
Feel free to contribute! Create a fork or report bug to improve this project
Build and test
./mvnw clean ; ./mvnw verify
Integration test (MySQL)
if [[ "" != `docker ps -aq` ]] ; then docker rm -f -v `docker ps -aq` ; fi
docker run -d --rm --name mysql --platform=linux/x86_64 \
--health-cmd='mysqladmin ping -h 127.0.0.1 -u $MYSQL_USER --password=$MYSQL_PASSWORD || exit 1' \
--health-start-period=1s --health-retries=1111 --health-interval=1s --health-timeout=5s \
-e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=database \
-e MYSQL_USER=user -e MYSQL_PASSWORD=password \
-p 3306:3306 \
mysql:8.0.24
while [[ $(docker ps -n 1 -q -f health=healthy -f status=running | wc -l) -lt 1 ]] ; do
sleep 3 ; echo -n '.'
done
sleep 15; echo 'MySQL is ready.'
rm -rf ~/.m2/repository/daggerok/liquibase/r2dbc*
./mvnw clean install -DskipTests
./mvnw -f examples/mysql spring-boot:start
http :8001
http :8001/api
http :8001/api/messages
http :8001/api/messages body=hey
http :8001/api/messages
./mvnw -f examples/mysql spring-boot:stop
docker stop mysql
Integration test (Postgresql)
if [[ "" != `docker ps -aq` ]] ; then docker rm -f -v `docker ps -aq` ; fi
docker run -d --rm --name postgres -p 5432:5432 --platform=linux/x86_64 \
-e POSTGRES_PASSWORD=password -e POSTGRES_DB=database -e POSTGRES_USER=user \
--health-start-period=1s --health-retries=1111 --health-interval=1s --health-timeout=5s \
--health-cmd='pg_isready -h 127.0.0.1 -p 5432 -d $POSTGRES_DB -U $POSTGRES_USER || exit 1' \
postgres:14.3-alpine3.16
while [[ $(docker ps -n 1 -q -f health=healthy -f status=running | wc -l) -lt 1 ]] ; do
sleep 3 ; echo -n '.'
done
rm -rf ~/.m2/repository/daggerok/liquibase/r2dbc*
./mvnw clean install -DskipTests
./mvnw -f examples/postgresql spring-boot:start
http :8002
http :8002/api
http :8002/api/messages
http :8002/api/messages body=hey
http :8002/api/messages
./mvnw -f examples/postgresql spring-boot:stop
docker stop postgres
Integration test (H2 file)
rm -rf ~/.m2/repository/daggerok/liquibase/r2dbc*
./mvnw clean install -DskipTests
./mvnw -f examples/h2/file spring-boot:start
http :8003
http :8003/api
http :8003/api/messages
http :8003/api/messages body=hey
http :8003/api/messages
./mvnw -f examples/h2/file spring-boot:stop
Integration test (H2 mem)
rm -rf ~/.m2/repository/daggerok/liquibase/r2dbc*
./mvnw clean install -DskipTests
./mvnw -f examples/h2/mem spring-boot:start
http :8004
http :8004/api
http :8004/api/messages
http :8004/api/messages body=hey
http :8004/api/messages
./mvnw -f examples/h2/mem spring-boot:stop
Integration test (H2 tcp file)
if [[ "" != `docker ps -aq` ]] ; then docker rm -f -v `docker ps -aq` ; fi
docker run -p 3306:3306 -d --rm --name mariadb --platform=linux/x86_64 \
--env MARIADB_USER=user --env MARIADB_PASSWORD=password --env MARIADB_ROOT_PASSWORD=password --env MARIADB_DATABASE=database \
--health-cmd='mysqladmin ping -h 127.0.0.1 -u $MARIADB_USER --password=$MARIADB_PASSWORD || exit 1' \
--health-start-period=1s --health-retries=1111 --health-interval=1s --health-timeout=5s \
mariadb:10.7.4
while [[ $(docker ps -n 1 -q -f health=healthy -f status=running | wc -l) -lt 1 ]] ; do
sleep 3 ; echo -n '.'
done
echo 'MariaDB is ready.'
rm -rf ~/.m2/repository/daggerok/liquibase/r2dbc*
./mvnw clean install -DskipTests
./mvnw -f examples/mariadb spring-boot:start
http :8005
http :8005/api
http :8005/api/messages
http :8005/api/messages body=hey
http :8005/api/messages
./mvnw -f examples/mariadb spring-boot:stop
Integration test (MariaDB)
if [[ "" != `docker ps -aq` ]] ; then docker rm -f -v `docker ps -aq` ; fi
docker run -p 3306:3306 -d --rm --name mariadb --platform=linux/x86_64 \
--env MARIADB_USER=user --env MARIADB_PASSWORD=password --env MARIADB_ROOT_PASSWORD=password --env MARIADB_DATABASE=database \
--health-cmd='mysqladmin ping -h 127.0.0.1 -u $MARIADB_USER --password=$MARIADB_PASSWORD || exit 1' \
--health-start-period=1s --health-retries=1111 --health-interval=1s --health-timeout=5s \
mariadb:10.7.4
while [[ $(docker ps -n 1 -q -f health=healthy -f status=running | wc -l) -lt 1 ]] ; do
sleep 3 ; echo -n '.'
done
echo 'MariaDB is ready.'
rm -rf ~/.m2/repository/daggerok/liquibase/r2dbc*
./mvnw clean install -DskipTests
./mvnw -f examples/mariadb spring-boot:start
http :8005
http :8005/api
http :8005/api/messages
http :8005/api/messages body=hey
http :8005/api/messages
./mvnw -f examples/mariadb spring-boot:stop