Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Migrate | 11,589 | 594 | a day ago | 129 | March 17, 2022 | 273 | other | Go | ||
Database migrations. CLI and Golang library. | ||||||||||
Flyway | 7,203 | 4,044 | 442 | 2 days ago | 156 | September 08, 2022 | 118 | apache-2.0 | Java | |
Flyway by Redgate • Database Migrations Made Easy. | ||||||||||
Pgloader | 4,469 | a month ago | 1 | February 27, 2018 | 295 | other | Common Lisp | |||
Migrate to PostgreSQL in a single command! | ||||||||||
Phinx | 4,376 | 3,494 | 437 | 8 days ago | 82 | January 21, 2022 | 137 | mit | PHP | |
PHP Database Migrations for Everyone | ||||||||||
Goose | 3,954 | 65 | 99 | 6 days ago | 46 | August 29, 2022 | 57 | other | Go | |
A database migration tool. Supports SQL migrations and Go functions. | ||||||||||
Dbmate | 3,432 | 1 | 9 days ago | 27 | March 25, 2022 | 16 | mit | Go | ||
:rocket: A lightweight, framework-agnostic database migration tool. | ||||||||||
Fluentmigrator | 2,955 | 548 | 130 | 4 days ago | 52 | January 14, 2022 | 221 | apache-2.0 | C# | |
Fluent migrations framework for .NET | ||||||||||
Express Typescript Boilerplate | 2,946 | a month ago | 94 | mit | TypeScript | |||||
A delightful way to building a RESTful API with NodeJs & TypeScript by @w3tecch | ||||||||||
Nyaa | 2,861 | 2 years ago | 61 | gpl-3.0 | Python | |||||
Bittorrent software for cats | ||||||||||
Simplebank | 2,594 | 1 | 2 months ago | 6 | April 11, 2021 | 4 | mit | Go | ||
Backend master class: build a simple bank service in Go |
Generic migration tool for RDBMS and other resources based on Liquibase.
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'
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 {
...
}
}
);
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.
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.
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>
SqlMigration
migrates the database by native SQL.
In the default, LiquibaseMigration
and SqlMigration
try to load a file from classpath as following order:
_${database}
name suffix (if specified)${moduleId}_${version}_${database}.${extension}
${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).
To release arifacts, run the following command:
$ mvn deploy -DperformRelease=true -DskipTests