{"id":19725628,"url":"https://github.com/xdev-software/micro-migration","last_synced_at":"2025-04-30T00:31:29.950Z","repository":{"id":64108789,"uuid":"572860963","full_name":"xdev-software/micro-migration","owner":"xdev-software","description":"Tiny library to migrate EclipseStore datastores. Applies migration scripts on the datastores to keep them up to date.","archived":false,"fork":false,"pushed_at":"2024-11-08T02:31:14.000Z","size":1393,"stargazers_count":18,"open_issues_count":9,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2024-11-08T03:28:54.879Z","etag":null,"topics":["eclipse-store","eclipsestore","java","maven","support-library","xdev"],"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/xdev-software.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-01T07:27:24.000Z","updated_at":"2024-11-04T03:09:11.000Z","dependencies_parsed_at":"2024-01-22T10:53:43.845Z","dependency_job_id":"e14c29b9-ab62-49b7-89a4-650dc60614b8","html_url":"https://github.com/xdev-software/micro-migration","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdev-software%2Fmicro-migration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdev-software%2Fmicro-migration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdev-software%2Fmicro-migration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xdev-software%2Fmicro-migration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xdev-software","download_url":"https://codeload.github.com/xdev-software/micro-migration/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224191444,"owners_count":17271047,"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":["eclipse-store","eclipsestore","java","maven","support-library","xdev"],"created_at":"2024-11-11T23:31:44.557Z","updated_at":"2025-04-30T00:31:29.941Z","avatar_url":"https://github.com/xdev-software.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest version](https://img.shields.io/maven-central/v/software.xdev/micro-migration?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/micro-migration)\n[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/micro-migration/check-build.yml?branch=develop)](https://github.com/xdev-software/micro-migration/actions/workflows/check-build.yml?query=branch%3Adevelop)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_micro-migration\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_micro-migration)\n\n# \u003cimg src=\"assets/Logo.png\" width=\"400\" alt=\"XDEV MicroMigration Logo\"\u003e\nTiny java library to migrate [EclipseStore](https://github.com/eclipse-store/store) datastores. \nApplies migration scripts on the datastores to keep them up to date.\n\n## Intro\nWhen you think about default database setup, you probably imagine something like this:\n\n![Imaginative system layout](./assets/MigrationSequence_1.png \"Imaginative system layout\")\n\nYet in reality most workflows involve different systems like test systems and production systems. \nIn code this workflow is represented with version-control systems and different branches.\n\n![Code workflow](./assets/MigrationSequence_2.png \"Code workflow\")\n\nFor this code workflow to behave correctly, for each system a separate datastore is needed.\nTo keep these datastores to represent the correspondend data for the code is a hassle.\n\n![Code workflow with datastore](./assets/MigrationSequence_3.png \"Code workflow with datastore\")\n\nThat's why migration frameworks like [Flyway](https://flywaydb.org) and [Liquibase](https://www.liquibase.org/) exist.\nUnfortunately both these frameworks are designed to support any type of SQL databases but no NoSQL databases like [EclipseStore](https://eclipsestore.io/). This led to the creation of this library.\n\nThis library delivers an easy concept to keep your EclipseStore datastore versioned with migration scripts written in plain java.\nIt's easy to create code, that automatically brings a datastore with an older version to the version, suited to the current code.\n\n![Migrate datastore to new version](./assets/MigrationSequence_4.png \"Migrate datastore to new version\")\n\n## Approaches\nThere are two possible usages with the Micro migration library:\n\nThe **first**, easier approach is to use the `MigrationEmbeddedStorageManager`.\nIt can be used on a brand new datastore or introduced later, after a EclipseStore datastore is already in use.\nOnly the storage manager (`MigrationEmbeddedStorageManager`) knows about the versioning. \nThe rest of application does not know about the version and can have no regards about it.\n\n### MigrationEmbeddedStorageManager\nExtensive examples can be found in its own [own module](./micro-migration-demo).\nA simple example where scripts need to be registered in the `ExplicitMigrater`:\n\n```java\npublic static void main(String[] args){\n\tExplicitMigrater migrater = new ExplicitMigrater(new UpdateToV1_0());\n\tMigrationEmbeddedStorageManager storageManager = MigrationEmbeddedStorage.start(migrater);\n\t// Do some business logic\n\tstorageManager.shutdown();\n}\n```\n\nThe update scripts can look like this:\n\n```java\npublic class UpdateToV1_0 implements MigrationScript\u003cObject\u003e\n{\n\t@Override\n\tpublic MigrationVersion getTargetVersion(){\n\t\treturn new MigrationVersion(1);\n\t}\n\t\n\t@Override\n\tpublic void migrate(Context\u003cString, EmbeddedStorageManager\u003e context){\n\t\t// Logic of the update\n\t\tcontext.getStorageManager().setRoot(\"Update 1.0\");\n\t}\n}\n```\n\n### MigrationManager\nAlthough the approach with the `MigrationEmbeddedStorageManager` is pretty easy to handle, it is intrusive in the way, that it replaces the root entry point of the EclipseStore datastore and inserts its own `VersionedRoot` as root. Some users might find this too entrusive.\n\nThat's why a second approach can be used, where the `MigrationManager` is used. This class is also used internally by the `MigrationEmbeddedStorageManager`. \n\n```java\npublic static void main(String[] args){\n\tExplicitMigrater migrater = new ExplicitMigrater(new UpdateToV1_0());\n\tEmbeddedStorageManager storageManager = EmbeddedStorage.start();\n\t\tVersionedObject\u003cObject\u003e versionedRoot =(VersionedObject\u003cObject\u003e)storageManager.root();\n\t\tnew MigrationManager(versionedRoot, migrater, storageManager).migrate(versionedBranch);\n\t// Do some business logic\n\tstorageManager.shutdown();\n}\n```\n\n## Migrater\n### ExplicitMigrater\nScripts for the migrations must be registered in a `MicroMigrater`. \nThe simplest way for this is to use the `ExplicitMigrater` and just put the scripts in the constructor.\nA downside of this method is that you need to register all scripts (new or old) manually in the constructor.\n\n```java\nfinal ExplicitMigrater migrater = new ExplicitMigrater(\n\tnew UpdateToV1_0(),\n\tnew UpdateToV1_1()\n);\n```\n\n### ReflectiveMigrater\nFor a more convenient usage the `ReflectiveMigrater` was built. \nYou simply instanciate a object of this class with the package name of your `MicroMigrationScript`s.\nThe `ReflectiveMigrater` will search for any implementations of `MicroMigrationScript` in the given package.\nThis way scripts can simply be placed in the same package and on startup of the application all scripts are loaded in.\n\n```java\nfinal ReflectiveMigrater migrater = new ReflectiveMigrater(\"software.xdev.micromigration.examples.reflective.scripts\");\n```\n\n## Installation\n[Installation guide for the latest release](https://github.com/xdev-software/micro-migration/releases/latest#Installation)\n\n### Compatibility\n\n| Eclipse Store version                                             | micro-migration version |\n|-------------------------------------------------------------------|-------------------------|\n| [EclipseStore](https://github.com/eclipse-store/store) 2+         | ``3+``                  |\n| [EclipseStore](https://github.com/eclipse-store/store) 1+         | ``2.x``                 |\n| [MicroStream](https://github.com/microstream-one/microstream) 5-8 | ``1.x``                 |\n\n## Support\nIf you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support).\n\n## Contributing\nSee the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.\n\n## Dependencies and Licenses\nView the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/micro-migration/dependencies)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxdev-software%2Fmicro-migration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxdev-software%2Fmicro-migration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxdev-software%2Fmicro-migration/lists"}