{"id":20171949,"url":"https://github.com/harwoeck/adapt","last_synced_at":"2026-02-12T22:08:11.148Z","repository":{"id":57618536,"uuid":"387846077","full_name":"harwoeck/adapt","owner":"harwoeck","description":"📦 adapt is a simple general-purpose migration library that gets embedded into your Go application","archived":false,"fork":false,"pushed_at":"2024-02-05T15:54:32.000Z","size":111,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T02:57:52.405Z","etag":null,"topics":["adapt","db-migration","go","go-library","golang","migration","migration-library","migration-tool"],"latest_commit_sha":null,"homepage":"","language":"Go","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/harwoeck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2021-07-20T16:06:17.000Z","updated_at":"2024-02-17T09:04:46.000Z","dependencies_parsed_at":"2024-06-20T00:24:14.053Z","dependency_job_id":null,"html_url":"https://github.com/harwoeck/adapt","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/harwoeck/adapt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harwoeck%2Fadapt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harwoeck%2Fadapt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harwoeck%2Fadapt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harwoeck%2Fadapt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harwoeck","download_url":"https://codeload.github.com/harwoeck/adapt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harwoeck%2Fadapt/sbom","scorecard":{"id":456672,"data":{"date":"2025-08-11","repo":{"name":"github.com/harwoeck/adapt","commit":"b9ae7c3bcba54305ac48acce247257e7e8c61646"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/15 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T09:52:52.038Z","repository_id":57618536,"created_at":"2025-08-19T09:52:52.038Z","updated_at":"2025-08-19T09:52:52.038Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29382982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T22:07:52.078Z","status":"ssl_error","status_checked_at":"2026-02-12T22:07:49.026Z","response_time":55,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["adapt","db-migration","go","go-library","golang","migration","migration-library","migration-tool"],"created_at":"2024-11-14T01:28:32.912Z","updated_at":"2026-02-12T22:08:11.133Z","avatar_url":"https://github.com/harwoeck.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"adapt-logo.png\"\u003e\u003c/img\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003cbr\u003e\n      \u003ci\u003eadapt\u003c/i\u003e is a simple, non-magical general purpose migration library that gets embedded into your application.\u003cbr\u003e\n      \u003cimg width=\"2000\" height=\"0\"\u003e\n    \u003c/td\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n### Features\n\n- 🟢 **Simplicity:** Migration lifecycle and schema versioning is completely abstracted and managed by _adapt_\n- 🟢 **Concurrency controlled (protected from race-conditions):** Mutexes and other techniques are used to prevent multiple _adapt_ instances conflicting each other during concurrent boot-ups\n- 🟢 **Extensible:** Simple `Driver` and migration `Source` interfaces\n- 🟢 **Migrations:** can be provided in a variety of ways and get merged and sorted into a single migration-collection, which is applied against the version-controlled schema in your storage\n    - **Go Code** for all non-database migrations or situations where SQL doesn't do the job\n    - **Embed migration folders** containing your SQL scripts\n    - Hardcoded SQL statements\n- 🟢 **Branching and merging compatible:** _adapt_ automatically catches up with missing migrations (\"holes\")\n- 🟢 **Zero** external dependencies\n- 🟢 **Customizable Logging:** _adapt_ uses [`slog`](https://pkg.go.dev/log/slog) [included with Go 1.21+](https://go.dev/blog/slog) so that you can provide your own logging backend.\n\n#### Supported Storage `Driver`\n\n- [File](https://pkg.go.dev/github.com/harwoeck/adapt#NewFileDriver) - Basic driver that stores migration meta-data in a local JSON file (demonstrates how a `Driver` without any reliance or dependency on `database/sql` can be written.)\n- [MySQL / MariaDB](https://pkg.go.dev/github.com/harwoeck/adapt#NewMySQLDriver)\n- [SQLite](https://pkg.go.dev/github.com/harwoeck/adapt#NewSQLiteDriver)\n- [PostgreSQL](https://pkg.go.dev/github.com/harwoeck/adapt#NewPostgresDriver)\n- [Add driver ?](https://github.com/harwoeck/adapt/issues/new)\n\n**Any other storage backend** by providing your own [`Driver`](https://pkg.go.dev/github.com/harwoeck/adapt#Driver), [`DatabaseDriver`](https://pkg.go.dev/github.com/harwoeck/adapt#DatabaseDriver) or [`SqlStatementsDriver`](https://pkg.go.dev/github.com/harwoeck/adapt#SqlStatementsDriver). Unlike most other migration tools, with _adapt_ there is no reliance on `database/sql` (such a case can be seen with the included `FileDriver`)\n\n#### Supported Migrations\n\n- [Go Code](https://pkg.go.dev/github.com/harwoeck/adapt#NewCodePackageSource)\n- [Filesystem](https://pkg.go.dev/github.com/harwoeck/adapt#NewFilesystemSource)\n- [In-memory](https://pkg.go.dev/github.com/harwoeck/adapt#NewMemoryFSSource)\n- [Embedded Filesystem](https://pkg.go.dev/github.com/harwoeck/adapt#NewEmbedFSSource) - Using Go 1.16+ [go:embed](https://pkg.go.dev/embed)\n\n\u003e [!NOTE]\n\u003e Please support this project and provide additional sources that could be useful for other people\n\n### Install\n\n```bash\n$ go get github.com/harwoeck/adapt\n```\n\n## Usage\n\n```go\nvar db *sql.DB = initDB()\n\nerr := adapt.Migrate(\n    \"backend@v0.1.17\",                      // \u003cname\u003e of executor\n    adapt.NewMySQLDriver(db),               // Database driver\n    adapt.SourceCollection{\n        adapt.NewFilesystemSource(\"./sql\"), // SQL-Migration-Scripts from filesystem\n    })\n```\n\n\u003e [!NOTE]\n\u003e **Next example:** Due to compliance rules you decide to encrypt your users email addresses inside your database. Since this requires actual Go code (and not just SQL statements), you could implement one of the [`adapt.Hook`](https://pkg.go.dev/github.com/harwoeck/adapt#Hook) functions and during your next deployment _adapt_ will notice this new unapplied migration and execute your hook. When no error is returned _adapt_ will commit the transaction and update the schema table with the relevant meta information.\n\n```go\nerr := adapt.Migrate(\n    \"backend@v0.1.17\",                      // \u003cname\u003e of executor\n    adapt.NewMySQLDriver(db),               // Database driver\n    adapt.SourceCollection{                 // adapt will automatically merge and sort all provided sources for you\n        adapt.NewFilesystemSource(\"./sql\"), // SQL-Migration-Scripts from filesystem\n        adapt.NewCodeSource(\"2020-04-17_1104_encrypt-user-email\", adapt.Hook{\n            MigrateUpTx: func(tx *sql.Tx) error {\n                // For this encrypt-migration you could use `MigrateUpTx` to load\n                // the rows, encrypt the content in Go and update the columns again\n                // within a single managed transaction.\n                return nil\n            },\n        },\n    })\n```\n\n## Inspired by\n\nThis project was heavily inspired by the features and ideas of these great projects:\n\n- https://www.liquibase.org\n- https://github.com/Boostport/migration\n- https://github.com/lopezator/migrator\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharwoeck%2Fadapt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharwoeck%2Fadapt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharwoeck%2Fadapt/lists"}