All Projects → gitbucket → solidbase

gitbucket / solidbase

Licence: Apache-2.0 license
Generic migration tool for RDBMS and other resources based on Liquibase

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to solidbase

django-wordpress-parser
Wordpress eXtended RSS Parser (in Python for Django)
Stars: ✭ 18 (-43.75%)
Mutual labels:  migration
liquibase-slf4j
Liquibase SLF4J Logger.
Stars: ✭ 42 (+31.25%)
Mutual labels:  liquibase
AngularVueIntegration
An opinionated attempt to let Angular 1.x and Vue peacefully live together
Stars: ✭ 28 (-12.5%)
Mutual labels:  migration
yii2-console-migration
yii2命令行中使用migration备份和还原数据库
Stars: ✭ 35 (+9.38%)
Mutual labels:  migration
toggl2clockify
Migrate data from toggl to clockify
Stars: ✭ 21 (-34.37%)
Mutual labels:  migration
jetbrains-gradle-plugins
Gradle plugins for Docker, Terraform and Liquibase.
Stars: ✭ 22 (-31.25%)
Mutual labels:  liquibase
upscheme
Database migrations and schema updates made easy
Stars: ✭ 737 (+2203.13%)
Mutual labels:  migration
Remove-DuplicateItems
Script to remove duplicate items from Exchange mailboxes.
Stars: ✭ 32 (+0%)
Mutual labels:  migration
tracboat
Trac to GitLab migration toolbox
Stars: ✭ 32 (+0%)
Mutual labels:  migration
DataMigrationTeam
Repository for the Data Migration Team
Stars: ✭ 107 (+234.38%)
Mutual labels:  migration
harmonica
Kotlin Database Migration Tool. This tool makes it really easy to create table, index, add columns, and so on, with Kotlin DSL.
Stars: ✭ 123 (+284.38%)
Mutual labels:  migration
pgcapture
A scalable Netflix DBLog implementation for PostgreSQL
Stars: ✭ 94 (+193.75%)
Mutual labels:  migration
pg-migrate
PostgreSQL migration tool
Stars: ✭ 39 (+21.88%)
Mutual labels:  migration
kanban-board
Single-click full-stack application (Postgres, Spring Boot & Angular) using Docker Compose
Stars: ✭ 138 (+331.25%)
Mutual labels:  liquibase
php-mongo-migrator
Migrations of MongoDB. Part of @PHPMongoKit
Stars: ✭ 29 (-9.37%)
Mutual labels:  migration
spring-projects
Some spring sample projects
Stars: ✭ 24 (-25%)
Mutual labels:  liquibase
migrana
Migrana is a Datomic migration tool that gives you the control over how your Datomic database evolves.
Stars: ✭ 22 (-31.25%)
Mutual labels:  migration
ProcessMigrator
ProcessWire module that facilitates automated migration and sharing of page trees along with their templates and fields.
Stars: ✭ 29 (-9.37%)
Mutual labels:  migration
vault-migrator
migrate vault data between different physical backends
Stars: ✭ 51 (+59.38%)
Mutual labels:  migration
aurelia-knockout
Adds support for Knockout binding syntax to make transition from Durandal and Knockout to Aurelia simpler.
Stars: ✭ 22 (-31.25%)
Mutual labels:  migration

Solidbase build Maven Central License

Generic migration tool for RDBMS and other resources based on Liquibase.

  • Multi-database (based on Liquibase)
  • Multi-resource (not only RDBMS)
  • Multi-module (modules can have their own versions)

Usage

Add dependency

Add following dependency into your Maven pom.xml:

<dependencies>
  <dependency>
    <groupId>io.github.gitbucket</groupId>
    <artifactId>solidbase</artifactId>
    <version>1.0.5</version>
  </dependency>
</dependencies>

or for Gradle add to build.gradle:

implementation 'io.github.gitbucket:solidbase:1.0.5'

Define migration

Create the Liquibase migration xml files under src/main/resources. For example:

  • src/main/resources/test_1.0.0.xml

    <changeSet>
      <createTable tableName="person">
          <column name="id" type="int" autoIncrement="true" primaryKey="true" nullable="false"/>
          <column name="firstname" type="varchar(50)"/>
          <column name="lastname" type="varchar(50)" constraints nullable="false"/>
          <column name="state" type="char(2)"/>
      </createTable>
    </changeSet>

Define migration that migrates RDBMS using these XML files:

import io.github.gitbucket.solidbase.migration.LiquibaseMigration;
import io.github.gitbucket.solidbase.model.Module;
import io.github.gitbucket.solidbase.model.Version;

Module module = new Module(
  // module id
  "test",
  // versions (oldest first)
  new Version("1.0.0", new LiquibaseMigration("test_1.0.0.xml")),
  new Version("1.0.1", new LiquibaseMigration("test_1.0.1.xml")),
  ...
);

You can also add a migration for resources other than RDBMS by implementing Migration interface. Added migrations are executed in order.

import io.github.gitbucket.solidbase.migration.LiquibaseMigration;
import io.github.gitbucket.solidbase.migration.Migration;

new Version("1.0.0",
  // At first, migrate RDBMS
  new LiquibaseMigration("test_1.0.0.xml"),
  // Second, migrate other resources
  new Migration(){
    @Override
    public void migrate(String moduleId, String version, Map<String, Object> context) throws Exception {
      ...
    }
  }
);

Run

Then, run migration as below:

import io.github.gitbucket.solidbase.SolidBase;
import java.sql.DriverManager;
import liquibase.database.core.H2Database;

Solidbase solidbase = new Solidbase();

solidbase.migrate(
  DriverManager.getConnection("jdbc:h2:mem:test", "sa", "sa"),
  Thread.currentThread().getContextClassLoader(),
  new H2Database(),
  module
);

Differences between the current version and the latest version are applied.

Background

Solidbase creates a following VERSIONS table to manage versions automatically:

Column name Data type Not Null
MODULE_ID (PK) VARCHAR(100) Yes
VERSION VARCHAR(100) Yes

Solidbase uses this table to know the current version. When migration of the new version is successful, it updates the version with the new version.

Migration

XML migration

LiquibaseMigration migrates the database by Liquibase like XML as above.

XML schema is improved from Liquibase to be possible to declare column information as attributes instead of nested elements. And a default variable ${currentDateTime} is available in the XML:

<insert tableName="person">
  <column name="firstname" value="root"/>
  <column name="lastname" value="root"/>
  <column name="registeredDate" valueDate="${currentDateTime}"/>
</insert>

SQL migration

SqlMigration migrates the database by native SQL.

Apply RDBMS specific configuration

In the default, LiquibaseMigration and SqlMigration try to load a file from classpath as following order:

  1. Specified path with _${database} name suffix (if specified)
  2. Specified path (if specified)
  3. ${moduleId}_${version}_${database}.${extension}
  4. ${moduleId}_${version}.${extension}

It's possible to apply different XML/SQL for each databases by creating multiple files such as gitbucket_1.0.0_h2.sql (for H2 database) and gitbucket_1.0.0_mysql.sql (for MySQL).

for Developers

To release arifacts, run the following command:

$ mvn deploy -DperformRelease=true -DskipTests
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].