{"id":19428457,"url":"https://github.com/gitbucket/solidbase","last_synced_at":"2025-04-09T22:19:04.258Z","repository":{"id":2066844,"uuid":"45648458","full_name":"gitbucket/solidbase","owner":"gitbucket","description":"Generic migration tool for RDBMS and other resources based on Liquibase","archived":false,"fork":false,"pushed_at":"2025-03-22T22:34:41.000Z","size":138,"stargazers_count":35,"open_issues_count":9,"forks_count":6,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-09T22:18:52.170Z","etag":null,"topics":["database","java","liquibase","migration"],"latest_commit_sha":null,"homepage":"","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/gitbucket.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-06T00:19:18.000Z","updated_at":"2025-03-22T22:34:43.000Z","dependencies_parsed_at":"2023-12-05T00:25:14.451Z","dependency_job_id":"f07815c5-f84e-49f3-a6fd-77ebffc9569f","html_url":"https://github.com/gitbucket/solidbase","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fsolidbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fsolidbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fsolidbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitbucket%2Fsolidbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gitbucket","download_url":"https://codeload.github.com/gitbucket/solidbase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119283,"owners_count":21050755,"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","java","liquibase","migration"],"created_at":"2024-11-10T14:15:19.128Z","updated_at":"2025-04-09T22:19:04.236Z","avatar_url":"https://github.com/gitbucket.png","language":"Java","readme":"# Solidbase [![build](https://github.com/gitbucket/solidbase/workflows/build/badge.svg?branch=master)](https://github.com/gitbucket/solidbase/actions?query=workflow%3Abuild+branch%3Amaster) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.gitbucket/solidbase/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.gitbucket/solidbase) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/gitbucket/solidbase/blob/master/LICENSE)\n\nGeneric migration tool for RDBMS and other resources based on [Liquibase](http://www.liquibase.org/).\n\n- Multi-database (based on Liquibase)\n- Multi-resource (not only RDBMS)\n- Multi-module (modules can have their own versions)\n\n## Usage\n\n### Add dependency\n\nAdd following dependency into your Maven `pom.xml`:\n\n```xml\n\u003cdependencies\u003e\n  \u003cdependency\u003e\n    \u003cgroupId\u003eio.github.gitbucket\u003c/groupId\u003e\n    \u003cartifactId\u003esolidbase\u003c/artifactId\u003e\n    \u003cversion\u003e1.1.0\u003c/version\u003e\n  \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\nor for Gradle add to `build.gradle`:\n```groovy\nimplementation 'io.github.gitbucket:solidbase:1.0.5'\n```\n### Define migration\n\nCreate the Liquibase migration xml files under `src/main/resources`. For example:\n\n- `src/main/resources/test_1.0.0.xml`\n\n  ```xml\n  \u003cchangeSet\u003e\n    \u003ccreateTable tableName=\"person\"\u003e\n      \u003ccolumn name=\"id\" type=\"int\" autoIncrement=\"true\" primaryKey=\"true\" nullable=\"false\"/\u003e\n      \u003ccolumn name=\"firstname\" type=\"varchar(50)\"/\u003e\n      \u003ccolumn name=\"lastname\" type=\"varchar(50)\" nullable=\"false\"/\u003e\n      \u003ccolumn name=\"state\" type=\"char(2)\"/\u003e\n    \u003c/createTable\u003e\n  \u003c/changeSet\u003e\n  ```\n\nDefine migration that migrates RDBMS using these XML files:\n\n```java\nimport io.github.gitbucket.solidbase.migration.LiquibaseMigration;\nimport io.github.gitbucket.solidbase.model.Module;\nimport io.github.gitbucket.solidbase.model.Version;\n\nModule module = new Module(\n  // module id\n  \"test\",\n  // versions (oldest first)\n  new Version(\"1.0.0\", new LiquibaseMigration(\"test_1.0.0.xml\")),\n  new Version(\"1.0.1\", new LiquibaseMigration(\"test_1.0.1.xml\")),\n  ...\n);\n```\n\nYou can also add a migration for resources other than RDBMS by implementing `Migration` interface. \nAdded migrations are executed in order.\n\n```java\nimport io.github.gitbucket.solidbase.migration.LiquibaseMigration;\nimport io.github.gitbucket.solidbase.migration.Migration;\n\nnew Version(\"1.0.0\",\n  // At first, migrate RDBMS\n  new LiquibaseMigration(\"test_1.0.0.xml\"),\n  // Second, migrate other resources\n  new Migration(){\n    @Override\n    public void migrate(String moduleId, String version, Map\u003cString, Object\u003e context) throws Exception {\n      ...\n    }\n  }\n);\n```\n\n### Run\n\nThen, run migration as below:\n\n```java\nimport io.github.gitbucket.solidbase.SolidBase;\nimport java.sql.DriverManager;\nimport liquibase.database.core.H2Database;\n\nSolidbase solidbase = new Solidbase();\n\nsolidbase.migrate(\n  DriverManager.getConnection(\"jdbc:h2:mem:test\", \"sa\", \"sa\"),\n  Thread.currentThread().getContextClassLoader(),\n  new H2Database(),\n  module\n);\n```\n\nDifferences between the current version and the latest version are applied.\n\n### Background\n\nSolidbase creates a following `VERSIONS` table to manage versions automatically:\n\n| Column name    | Data type    | Not Null |\n|:---------------|:-------------|:---------|\n| MODULE_ID (PK) | VARCHAR(100) | Yes      |\n| VERSION        | VARCHAR(100) | Yes      |\n\nSolidbase uses this table to know the current version. When migration of the new version is successful, it updates the version with the new version.\n\n## Migration\n\n### XML migration\n\n`LiquibaseMigration` migrates the database by Liquibase like XML as above.\n\nXML 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:\n\n```xml\n\u003cinsert tableName=\"person\"\u003e\n  \u003ccolumn name=\"firstname\" value=\"root\"/\u003e\n  \u003ccolumn name=\"lastname\" value=\"root\"/\u003e\n  \u003ccolumn name=\"registeredDate\" valueDate=\"${currentDateTime}\"/\u003e\n\u003c/insert\u003e\n```\n\n### SQL migration\n\n`SqlMigration` migrates the database by native SQL.\n\n### Apply RDBMS specific configuration\nIn the default, `LiquibaseMigration` and `SqlMigration` try to load a file from classpath as following order:\n\n1. Specified path with `_${database}` name suffix (if specified)\n2. Specified path (if specified)\n3. `${moduleId}_${version}_${database}.${extension}`\n4. `${moduleId}_${version}.${extension}`\n\nIt'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).\n\n## for Developers\n\nTo release arifacts, run the following command:\n\n```\n$ mvn deploy -DperformRelease=true -DskipTests\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitbucket%2Fsolidbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitbucket%2Fsolidbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitbucket%2Fsolidbase/lists"}