{"id":19144422,"url":"https://github.com/maragudk/migrate","last_synced_at":"2025-04-05T11:10:37.224Z","repository":{"id":42904105,"uuid":"377482723","full_name":"maragudk/migrate","owner":"maragudk","description":"A simple database migration tool.","archived":false,"fork":false,"pushed_at":"2025-03-24T12:52:22.000Z","size":89,"stargazers_count":50,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T10:09:09.358Z","etag":null,"topics":["database-migrations","go"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maragudk.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-06-16T12:06:35.000Z","updated_at":"2025-03-24T12:50:56.000Z","dependencies_parsed_at":"2024-11-09T07:37:49.798Z","dependency_job_id":"0a9ca99c-5527-4ec2-8bd9-0818c19babe6","html_url":"https://github.com/maragudk/migrate","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/maragudk%2Fmigrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maragudk%2Fmigrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maragudk%2Fmigrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maragudk%2Fmigrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maragudk","download_url":"https://codeload.github.com/maragudk/migrate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247325693,"owners_count":20920714,"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-migrations","go"],"created_at":"2024-11-09T07:34:55.682Z","updated_at":"2025-04-05T11:10:37.202Z","avatar_url":"https://github.com/maragudk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Migrate\n\n[![GoDoc](https://pkg.go.dev/badge/maragu.dev/migrate)](https://pkg.go.dev/maragu.dev/migrate)\n[![CI](https://github.com/maragudk/migrate/actions/workflows/ci.yml/badge.svg)](https://github.com/maragudk/migrate/actions/workflows/ci.yml)\n\nA simple database migration tool using an `sql.DB` connection and `fs.FS` for the migration source. It has no non-test dependencies.\n\nMade with ✨sparkles✨ by [maragu](https://www.maragu.dev/).\n\nDoes your company depend on this project? [Contact me at markus@maragu.dk](mailto:markus@maragu.dk?Subject=Supporting%20your%20project) to discuss options for a one-time or recurring invoice to ensure its continued thriving.\n\n## Features\n\n- Simple: The common usage is a one-liner.\n- Safe: Each migration is run in a transaction, and automatically rolled back on errors.\n- Flexible: Setup a custom migrations table and use callbacks before and after each migration.\n\n## Usage\n\n```shell\ngo get maragu.dev/migrate\n```\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"database/sql\"\n\t\"os\"\n\n\t_ \"github.com/jackc/pgx/v4/stdlib\"\n\t\"maragu.dev/migrate\"\n)\n\n// migrations is a directory with sql files that look something like this:\n// migrations/1-accounts.up.sql\n// migrations/1-accounts.down.sql\n// migrations/2-users.up.sql\n// migrations/2-users.down.sql\nvar migrations = os.DirFS(\"migrations\")\n\nfunc main() {\n\tdb, err := sql.Open(\"pgx\", \"postgresql://postgres:123@localhost:5432/postgres?sslmode=disable\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err := migrate.Up(context.Background(), db, migrations); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err := migrate.Down(context.Background(), db, migrations); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err := migrate.To(context.Background(), db, migrations, \"1-accounts\"); err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\n### Helper tool\n\nTo install the helper tool, run:\n\n```shell\ngo install maragu.dev/migrate/cmd/migrate@latest\n```\n\nThen you can run `migrate` in your terminal.\n\n```shell\nmigrate create sql/migrations accounts\n```\n\nFrom Go 1.24, you can also add it as a tool dependency in your `go.mod` file:\n\n```shell\ngo get -tool maragu.dev/migrate/cmd/migrate\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaragudk%2Fmigrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaragudk%2Fmigrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaragudk%2Fmigrate/lists"}