Inspired by this announcement. R2DBC page.
It supports user-provided dialect. You can pass implementation of SqlQueries
interface to the migrate()
method. If you use Spring Boot, just define a bean of type SqlQueries
. Example SimplePostgresqlDialect.
ConnectionFactory
provided by Spring BootV3__insert_to_customers__split,nontransactional.sql
classpath:/db/migration/*.sql
. It is configurable through r2dbc.migrate.resources-paths
.V0__create_schemas__premigration.sql
. Those scripts are invoked every time before entire migration process(e. g. before migration tables created), so you need to make them idempotent. You can use zero or negative version number(s): V-1__create_schemas__nontransactional,premigration.sql
. See example.-Xmx
: file will be split line-by-line (split
modifier), then it will be loaded by chunks into the database. Example.nontransactional
migrations, due to SQL Server 2017 prohibits CREATE DATABASE
in the transactionJUST_FILE
CONVENTIONALLY_NAMED_FILES
See the example in the two-modes
branch https://github.com/nkonev/r2dbc-migrate-example/blob/two-modes/src/main/resources/application.yml#L15.
All available configuration options are in R2dbcMigrateProperties class. Their descriptions are available in your IDE Ctrl+Space help or in spring-configuration-metadata.json file.
CREATE TABLE ... ON CONFLICT DO NOTHING
.MODE=PostgreSQL
. Use testcontainers with the real PostgreSQL.See here
<dependency>
<groupId>name.nkonev.r2dbc-migrate</groupId>
<artifactId>r2dbc-migrate-spring-boot-starter</artifactId>
<version>VERSION</version>
</dependency>
<dependency>
<groupId>name.nkonev.r2dbc-migrate</groupId>
<artifactId>r2dbc-migrate-core</artifactId>
<version>VERSION</version>
</dependency>
If you use library, you need also use some implementation of r2dbc-migrate-resource-reader-api
, for example:
<dependency>
<groupId>name.nkonev.r2dbc-migrate</groupId>
<artifactId>r2dbc-migrate-resource-reader-reflections</artifactId>
<version>VERSION</version>
</dependency>
See Library example
below.
https://github.com/nkonev/r2dbc-migrate-example
See example here.
https://github.com/nkonev/r2dbc-migrate-example/tree/library