{"id":19380255,"url":"https://github.com/tcfw/go-migrate","last_synced_at":"2026-04-18T05:33:47.581Z","repository":{"id":57544599,"uuid":"297190030","full_name":"tcfw/go-migrate","owner":"tcfw","description":"Stupidly simple SQL migrations","archived":false,"fork":false,"pushed_at":"2021-04-16T00:38:04.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T16:51:14.580Z","etag":null,"topics":["database","database-migrations","go","golang","golang-package","migrations","sql"],"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/tcfw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-21T00:34:49.000Z","updated_at":"2023-03-12T12:08:13.000Z","dependencies_parsed_at":"2022-08-27T05:13:25.253Z","dependency_job_id":null,"html_url":"https://github.com/tcfw/go-migrate","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tcfw/go-migrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcfw%2Fgo-migrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcfw%2Fgo-migrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcfw%2Fgo-migrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcfw%2Fgo-migrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcfw","download_url":"https://codeload.github.com/tcfw/go-migrate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcfw%2Fgo-migrate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31957623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["database","database-migrations","go","golang","golang-package","migrations","sql"],"created_at":"2024-11-10T09:13:23.530Z","updated_at":"2026-04-18T05:33:47.565Z","avatar_url":"https://github.com/tcfw.png","language":"Go","readme":"# go-migrate\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/tcfw/go-migrate)](https://pkg.go.dev/github.com/tcfw/go-migrate) [![Go Report Card](https://goreportcard.com/badge/github.com/tcfw/go-migrate)](https://goreportcard.com/report/github.com/tcfw/go-migrate)\n\nStupidly simple SQL migrations\n\nMigrations should be packages with your binary, so why not codify them!\n\n## Example migration\n```go\n//your-package/migrations/2020_09_21_115238_create_users_table.go\npackage migrations\n\nimport (\n\t\"database/sql\"\n\t\"time\"\n\n\t\"github.com/tcfw/go-migrate\"\n)\n\nfunc init() {\n\tregister(migrate.NewSimpleMigration(\n\t\t//Migration name to use in DB\n\t\t\"create_users_table\",\n\n\t\t//Timestamp of migration\n\t\ttime.Date(2020, 9, 21, 11, 52, 38, 0, time.Local),\n\n\t\t//Up\n\t\tfunc(tx *sql.Tx) error {\n\t\t\t_, err := tx.Exec(`CREATE TABLE users (\n\t\t\t\tid UUID PRIMARY KEY,\n\t\t\t\temail string\n\t\t\t)`)\n\t\t\treturn err\n\t\t},\n\n\t\t//Down\n\t\tfunc(tx *sql.Tx) error {\n\t\t\t_, err := tx.Exec(`DROP TABLE users`)\n\t\t\treturn err\n\t\t},\n\t))\n}\n\n```\n\n```go\n//your-package/migrations/migrations.go\npackage migrations\n\nimport (\n\t\"database/sql\"\n\t\"github.com/sirupsen/logrus\"\n\t\"github.com/tcfw/go-migrate\"\n)\n\n//migs List of known migrations\nvar migs migrate.MigrationList = migrate.MigrationList{}\n\n//register helper to register migrations from init\nfunc register(mig migrate.Migration) {\n\tmigs = append(migs, mig)\n}\n\n//Migrate runs migrations up (run in main or init)\nfunc Migrate(db *sql.DB, log *logrus.Logger) error {\n\treturn migrate.Migrate(db, log, migs)\n}\n\n```\n\n### Notes\n - File names are irrelevant which is why name and date are in the migration struct (possibly fix in future)\n - There's no auto migrate down like there is for up as increments aren't stored in groups (like in for example Laravel migrations in PHP) and it is assumed that if you are migrating down, it should probably be a manual process anyway\n - There is no DB table locking. \n - Any failures rollback the TX of the total increment over **multiple** migrations","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcfw%2Fgo-migrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcfw%2Fgo-migrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcfw%2Fgo-migrate/lists"}