Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/link-intersystems/dbunit-migration-maven-plugin

A maven plugin to migrate dbunit data sets via flyway with support from testcontainers.
https://github.com/link-intersystems/dbunit-migration-maven-plugin

Last synced: 6 days ago
JSON representation

A maven plugin to migrate dbunit data sets via flyway with support from testcontainers.

Awesome Lists containing this project

README

        

[![Maven Site](https://img.shields.io/badge/Maven-Site-brightgreen)](https://link-intersystems.github.io/dbunit-migration-maven-plugin/)
[![Maven Central](https://img.shields.io/maven-central/v/com.link-intersystems.dbunit.maven/dbunit-migration-maven-plugin)](https://mvnrepository.com/artifact/com.link-intersystems.dbunit.maven)
![Java CI with Maven](https://github.com/link-intersystems/dbunit-migration-maven-plugin/workflows/Java%20CI%20with%20Maven/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/link-intersystems/dbunit-migration-maven-plugin/badge.svg?branch=master)](https://coveralls.io/github/link-intersystems/dbunit-migration-maven-plugin?branch=master)
[![Open Issues](https://img.shields.io/github/issues/link-intersystems/dbunit-migration-maven-plugin)](https://github.com/link-intersystems/dbunit-migration-maven-plugin/issues)

The dbunit-migration-maven-plugin is a tool to migrate a collection of [DBUnit](http://dbunit.sourceforge.net/) data set files from one database schema
version to another with the use of [Flyway](https://flywaydb.org/) and [testcontainers](https://www.testcontainers.org/).

The overall process the plugin implements is:

1. Start a clean database with testcontainers.
2. Use Flyway to migrate the database to the version the data set files are based on.
3. Load a data set from a DBUnit file into the database.
4. Let Flyway migrate the database to a target version.
5. Use DBUnit to extract the database to a DBunit data set file.
6. Repeat for all data set files.

## Run

Run the plugin with

```
mvn com.link-intersystems.dbunit.maven:dbunit-migration-maven-plugin:1.0.3:flyway-migrate.
```

The plugin will output the files it migrates.

```shell
[info] Detected 4 data set resources to migrate
[info] ♻︎ Start migration '...\src\test\resources\flat\tiny-sakila-flat-column-sensing.xml'
[info] ✔︎ Migrated '...\target\flat\tiny-sakila-flat-column-sensing.xml'
[info] ♻︎ Start migration '...\src\test\resources\flat\tiny-sakila-flat.xml'
[info] ✔︎ Migrated '...\target\flat\tiny-sakila-flat.xml'
[info] ♻︎ Start migration '...\src\test\resources\tiny-sakila-csv'
[info] ✔︎ Migrated '...\target\tiny-sakila-csv'
[info] ♻︎ Start migration '...\src\test\resources\xml\tiny-sakila.xml'
[info] ✔︎ Migrated '...\target\xml\tiny-sakila.xml'
[info] Migrated 4 data set resources
```

## Minimal Plugin Configuration

This minimal plugin configuration will pick up all data sets under `${project.basedir}/src/test/resources`
that are based on flyway version 1 and migrate them to `${project.build.directory}`. The source directory structure will
be maintained.

```



com.link-intersystems.dbunit.maven
dbunit-migration-maven-plugin
RELEASE


1




postgres:latest



```

## Complete Plugin Configuration

The next section shows you all possible configuration options.

```



com.link-intersystems.dbunit.maven
dbunit-migration-maven-plugin
RELEASE


1
2

${project.basedir}/src/main/resources/db/migration


firstname

lastname




true
UTF-8



src/test/resources/tiny-sakila-csv
glob:**/*.xml
glob:*.xml
glob:**/*.xls
glob:*.xls




language
film
actor
film_actor







org.postgresql.Driver
jdbc:postgresql://{{host}}:{{port}}/{{env.POSTGRES_DB}}?loggerLevel=OFF
{{env.POSTGRES_USER}}
{{env.POSTGRES_PASSWORD}}
SELECT 1


5432

test
test
test


postgres
-c
fsync=off





http://www.dbunit.org/properties/datatypeFactory
org.dbunit.ext.postgresql.PostgresqlDataTypeFactory






```

Alternatively you can implement your own container support by implementing an
`com.link_intersystems.dbunit.testcontainers.DatabaseContainerSupportProvider`
and putting it on the classpath. It is registered using a `META-INF/services/com.link_intersystems.dbunit.testcontainers.DatabaseContainerSupportProvider`
file.

dbunit testcontainers comes with support for postgres and mysql.