{"id":16849539,"url":"https://github.com/boswelja/kotlin-migration","last_synced_at":"2026-01-11T17:35:25.150Z","repository":{"id":37756590,"uuid":"379832912","full_name":"boswelja/kotlin-migration","owner":"boswelja","description":"A Kotlin library to enable easier program migrations, inspired by AndroidX Room","archived":false,"fork":false,"pushed_at":"2025-12-27T04:17:46.000Z","size":547,"stargazers_count":6,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-28T20:16:22.738Z","etag":null,"topics":["kotlin","library","migration-tool"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/boswelja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["boswelja"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-06-24T06:58:24.000Z","updated_at":"2025-12-27T04:17:09.000Z","dependencies_parsed_at":"2023-02-18T00:31:48.719Z","dependency_job_id":"cdf0fb0a-d9f1-4de0-92eb-c1ba6863685c","html_url":"https://github.com/boswelja/kotlin-migration","commit_stats":null,"previous_names":["boswelja/android-migration"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/boswelja/kotlin-migration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boswelja%2Fkotlin-migration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boswelja%2Fkotlin-migration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boswelja%2Fkotlin-migration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boswelja%2Fkotlin-migration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boswelja","download_url":"https://codeload.github.com/boswelja/kotlin-migration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boswelja%2Fkotlin-migration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28315879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["kotlin","library","migration-tool"],"created_at":"2024-10-13T13:16:18.293Z","updated_at":"2026-01-11T17:35:25.133Z","avatar_url":"https://github.com/boswelja.png","language":"Kotlin","funding_links":["https://github.com/sponsors/boswelja"],"categories":[],"sub_categories":[],"readme":"# kotlin-migration\nA Kotlin library to enable easier program migrations, inspired by AndroidX Room\n\n## Usage\n\n### Add the dependency\n\n```kotlin\ndependencies {\n  implementation(\"io.github.boswelja.migration:migration-core:$version\")\n}\n```\n\n### Set up a `Migrator`\n\nThe basis of this library is a `Migrator`, that will run any `Migration` you give it. To create a `Migrator`, you should create your own class extending `Migrator`.\n\n```kotlin\nclass MigrationManager : Migrator(\n  currentVersion = 1,\n  migrations = listOf(\n    // Your migrations here\n  )\n) {\n  override suspend fun getOldVersion(): Int {\n    // You should fetch your previous version here\n    return 1\n  }\n}\n```\n\nThat's it! You can then call `migrate()` on an instance of your `Migrator` implementation.\n\n```kotlin\nval migrationManager = MigrationManager()\n\ncoroutineScope.launch {\n  migrationManager.migrate()\n}\n```\n\n### Creating Migrations\n\nCurrently, this library provides 2 types of migrations, `VersionMigration` and `ConditionalMigration`. Both should be passed into your `Migrator` constructor.\n\n#### `VersionMigration`\n\n```kotlin\nval migration1_2 = object : VersionMigration(fromVersion = 1, toVersion = 2) {\n  override suspend fun migrate(): Boolean {\n    // Do your migration here\n    return true\n  }\n}\n```\n\n#### `ConditionalMigration`\n\n```kotlin\nval migration1_2 = object : ConditionalMigration() {\n  override suspend fun shouldMigrate(fromVersion: Int): Boolean {\n    // Check whether this migration should be run, optionally taking a version into account\n    var shouldMigrate = ...\n    return shouldMigrate\n  }\n\n  override suspend fun migrate(): Boolean {\n    // Do your migration here\n    return true\n  }\n}\n```\n\n#### Creating your own migration type\n\nYou can implement the `Migration` interface on a class to build your own migration with more complex logic.\n\n```kotlin\nabstract class VersionMigration(\n  val fromVersion: Int,\n  final override val toVersion: Int\n) : Migration {\n  final override suspend fun shouldMigrate(fromVersion: Int): Boolean {\n    // Run this migration if fromVersion is the same as the version provided by the user\n    return fromVersion == this.fromVersion\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboswelja%2Fkotlin-migration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboswelja%2Fkotlin-migration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboswelja%2Fkotlin-migration/lists"}