{"id":14969086,"url":"https://github.com/nkonev/r2dbc-migrate","last_synced_at":"2025-04-04T14:06:52.202Z","repository":{"id":41964588,"uuid":"250418050","full_name":"nkonev/r2dbc-migrate","owner":"nkonev","description":"R2DBC database migration library","archived":false,"fork":false,"pushed_at":"2024-12-01T09:16:10.000Z","size":737,"stargazers_count":100,"open_issues_count":10,"forks_count":9,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-28T13:07:46.729Z","etag":null,"topics":["database-management","database-migrations","docker","mariadb","mariadb-database","mariadb-server","migrate","migration","mysql","postgres","postgresql","r2dbc","r2dbc-migration","spring-boot","sql-server","sqlserver"],"latest_commit_sha":null,"homepage":"https://nkonev.name/post/136","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nkonev.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-27T02:05:13.000Z","updated_at":"2024-12-30T05:29:45.000Z","dependencies_parsed_at":"2024-02-11T03:25:15.823Z","dependency_job_id":"7ecef7c0-fd28-4886-bec8-3e9827deb612","html_url":"https://github.com/nkonev/r2dbc-migrate","commit_stats":{"total_commits":557,"total_committers":2,"mean_commits":278.5,"dds":"0.037701974865350096","last_synced_commit":"0515efea441405107308a2b9a5c0c6c60211828e"},"previous_names":[],"tags_count":67,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkonev%2Fr2dbc-migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkonev%2Fr2dbc-migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkonev%2Fr2dbc-migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nkonev%2Fr2dbc-migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nkonev","download_url":"https://codeload.github.com/nkonev/r2dbc-migrate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247190250,"owners_count":20898702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-management","database-migrations","docker","mariadb","mariadb-database","mariadb-server","migrate","migration","mysql","postgres","postgresql","r2dbc","r2dbc-migration","spring-boot","sql-server","sqlserver"],"created_at":"2024-09-24T13:41:06.542Z","updated_at":"2025-04-04T14:06:52.187Z","avatar_url":"https://github.com/nkonev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# R2DBC migration library\n[![Maven Central](https://img.shields.io/maven-central/v/name.nkonev.r2dbc-migrate/r2dbc-migrate-core)](https://central.sonatype.com/namespace/name.nkonev.r2dbc-migrate)\n[![Build Status](https://github.com/nkonev/r2dbc-migrate/workflows/Java%20CI%20with%20Maven/badge.svg)](https://github.com/nkonev/r2dbc-migrate/actions)\n\nInspired by [this](https://spring.io/blog/2020/03/12/spring-boot-2-3-0-m3-available-now) announcement. R2DBC [page](https://r2dbc.io/).\n\n## Supported databases\n* PostgreSQL\n* Microsoft SQL Server\n* H2\n* MariaDB\n* MySQL\n\n\nIt 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](https://github.com/nkonev/r2dbc-migrate/blob/73acee24ee2963a0ffbc2f6ae64d07144367ce2f/r2dbc-migrate-core/src/test/java/name/nkonev/r2dbc/migrate/core/PostgresTestcontainersTest.java#L448).\n\n## Features\n* No need the dedicated JDBC params, r2dbc-migrate reuses your R2DBC `ConnectionFactory` provided by Spring Boot\n* Convention-based file names, for example `V3__insert_to_customers__split,nontransactional.sql`\n* Reasonable defaults. By convention, in case [Spring Boot](https://github.com/nkonev/r2dbc-migrate/blob/d65c7c49512a598dc4cc664bc33f78cb57ef3c43/r2dbc-migrate-spring-boot-starter/src/main/java/name/nkonev/r2dbc/migrate/autoconfigure/R2dbcMigrateAutoConfiguration.java#L60) SQL files should be placed in `classpath:/db/migration/*.sql`. It is configurable through `r2dbc.migrate.resources-paths`.\n* Pre-migration scripts, for example `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](https://github.com/nkonev/r2dbc-migrate/tree/master/r2dbc-migrate-core/src/test/resources/migrations/postgresql_premigration).\n* It waits until a database has been started, then performs test query, and validates its result. This can be useful for the initial data loading into database with docker-compose\n* Large SQL files support: migrations files larger than `-Xmx`: file will be split line-by-line (`split` modifier), then it will be loaded by chunks into the database. [Example](https://github.com/nkonev/r2dbc-migrate/blob/2.10.0/r2dbc-migrate-core/src/test/java/name/nkonev/r2dbc/migrate/core/PostgresTestcontainersTest.java#L230).\n* It supports lock, that make you able to start number of replicas your microservice, without care of migrations collide each other. Database-specific lock tracking [issue](https://github.com/nkonev/r2dbc-migrate/issues/28).\n* Each migration runs in the separated transaction by default\n* It also supports `nontransactional` migrations, due to SQL Server 2017 prohibits `CREATE DATABASE` in the transaction\n* First-class Spring Boot integration, see example below\n* Also, you can use this library without Spring (Boot), see library example below\n* This library tends to be non-invasive, consequently it intentionally doesn't try to parse SQL and make some decisions relying on. So (in theory) you can freely update the database and driver's version\n* Two modes of picking migration files \n    * index.html-like with explicit paths as in Liquibase - type `JUST_FILE`\n    * directories-scanning like as in Flyway - type `CONVENTIONALLY_NAMED_FILES`\n\nSee the example in the `two-modes` branch https://github.com/nkonev/r2dbc-migrate-example/blob/two-modes/src/main/resources/application.yml#L15.\n\nAll available configuration options are in [R2dbcMigrateProperties](https://github.com/nkonev/r2dbc-migrate/blob/master/r2dbc-migrate-core/src/main/java/name/nkonev/r2dbc/migrate/core/R2dbcMigrateProperties.java) class.\nTheir descriptions are available in your IDE Ctrl+Space help or in [spring-configuration-metadata.json](https://github.com/nkonev/r2dbc-migrate/blob/master/r2dbc-migrate-spring-boot-starter/src/main/resources/META-INF/spring-configuration-metadata.json) file.\n\n## Limitations\n* Currently, this library heavy relies on the upsert-like syntax like `CREATE TABLE ... ON CONFLICT DO NOTHING`.\nBecause this syntax isn't supported in H2 in PostresSQL compatibility mode, as a result, this library [can't be](https://github.com/nkonev/r2dbc-migrate/issues/21) run against H2 with `MODE=PostgreSQL`. Use [testcontainers](https://github.com/nkonev/r2dbc-migrate-example) with the real PostgreSQL.\n* Only forward migrations are supported. No backward migrations.\n* No [checksum](https://github.com/nkonev/r2dbc-migrate/issues/5) validation. As a result [repeatable](https://github.com/nkonev/r2dbc-migrate/issues/9) migrations aren't supported.\n\n## Compatibility (r2dbc-migrate, R2DBC Spec, Java, Spring Boot ...)\nSee [here](https://github.com/nkonev/r2dbc-migrate/issues/27#issuecomment-1404878933)\n\n## Download\n\n### Spring Boot Starter\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ename.nkonev.r2dbc-migrate\u003c/groupId\u003e\n  \u003cartifactId\u003er2dbc-migrate-spring-boot-starter\u003c/artifactId\u003e\n  \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Only library\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ename.nkonev.r2dbc-migrate\u003c/groupId\u003e\n    \u003cartifactId\u003er2dbc-migrate-core\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nIf you use library, you need also use some implementation of `r2dbc-migrate-resource-reader-api`, for example:\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ename.nkonev.r2dbc-migrate\u003c/groupId\u003e\n    \u003cartifactId\u003er2dbc-migrate-resource-reader-reflections\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\nSee `Library example` below.\n\n\n## Spring Boot example\nhttps://github.com/nkonev/r2dbc-migrate-example\n\n## Spring Native example\nSee example [here](https://github.com/nkonev/r2dbc-migrate-example/tree/native).\n\n## Library example\nhttps://github.com/nkonev/r2dbc-migrate-example/tree/library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnkonev%2Fr2dbc-migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnkonev%2Fr2dbc-migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnkonev%2Fr2dbc-migrate/lists"}