{"id":17757797,"url":"https://github.com/topi314/gomigrate","last_synced_at":"2026-04-29T23:05:01.434Z","repository":{"id":258267948,"uuid":"857912663","full_name":"topi314/gomigrate","owner":"topi314","description":"Golang SQL database schema migration library","archived":false,"fork":false,"pushed_at":"2025-06-04T00:19:07.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-01T22:32:36.118Z","etag":null,"topics":["database","database-migration","go","golang","migration","postgres","sqlite"],"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/topi314.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,"zenodo":null}},"created_at":"2024-09-15T23:31:12.000Z","updated_at":"2025-06-04T00:19:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"7faf800a-0fbe-43bf-a23a-0c18b986390d","html_url":"https://github.com/topi314/gomigrate","commit_stats":null,"previous_names":["topi314/gomigrate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/topi314/gomigrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topi314%2Fgomigrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topi314%2Fgomigrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topi314%2Fgomigrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topi314%2Fgomigrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/topi314","download_url":"https://codeload.github.com/topi314/gomigrate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/topi314%2Fgomigrate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32447312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"ssl_error","status_checked_at":"2026-04-29T22:10:49.234Z","response_time":110,"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":["database","database-migration","go","golang","migration","postgres","sqlite"],"created_at":"2024-10-26T17:08:43.643Z","updated_at":"2026-04-29T23:05:01.407Z","avatar_url":"https://github.com/topi314.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/topi314/gomigrate.svg)](https://pkg.go.dev/github.com/topi314/gomigrate)\n[![Go Report](https://goreportcard.com/badge/github.com/topi314/gomigrate)](https://goreportcard.com/report/github.com/topi314/gomigrate)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/topi314/gomigrate?filename=go.mod)](https://golang.org/doc/devel/release.html)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/topi314/gomigrate/blob/master/LICENSE)\n[![GoMigrate Version](https://img.shields.io/github/v/release/topi314/gomigrate?label=release)](https://github.com/topi314/gomigrate/releases/latest)\n\n# gomigrate\n\nGoMigrate is a SQL migration library for Go. It can support multiple databases such as SQLite, PostgreSQL, MySQL, and others.\n\n## Table of Contents\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to expand\u003c/summary\u003e\n\n- [Getting Started](#getting-started)\n    - [Prerequisites](#prerequisites)\n    - [Installing](#installing)\n- [Usage](#usage)\n    - [Create a migrations](#create-a-migrations)\n    - [Run migrations](#run-migrations)\n- [Examples](#examples)\n- [Troubleshooting](#troubleshooting)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003c/details\u003e\n\n## Getting Started\n\n### Prerequisites\n\n* Go 1.24 or later\n* SQLite, PostgreSQL, MySQL, or other databases\n* Go driver for the database you want to use\n\n### Installing\n\n```sh\ngo get github.com/topi314/gomigrate\n```\n\n## Usage\n\n### Create a migrations\n\nCreate a new folder named `migrations` and create a file with the following naming convention `VERSION_NAME.sql` (`VERSION_NAME.DRIVER.sql`) where `VERSION` is a number, `NAME` is a name of the migration \u0026 `DRIVER` (optional) is the name of the database driver this migration is for.\nAs an example: `01_create_users_table.sql`, `01_create_users_table.postgres.sql`, `02_add_email_to_users_table.sql` or `02_add_email_to_users_table.sqlite.sql`.\n\n`01_create_users_table.sql`\n\n```sql\n-- create users table\nCREATE TABLE users\n(\n    id   SERIAL PRIMARY KEY,\n    name VARCHAR NOT NULL\n);\n\n```\n\n`01_create_users_table.postgres.sql`\n\n```sql\n-- create users table for PostgreSQL\nCREATE TABLE users\n(\n    id   SERIAL PRIMARY KEY,\n    name VARCHAR NOT NULL\n);\n\n```\n\n`02_add_email_to_users_table.sql`\n\n```sql\n-- add email column to users table\nALTER TABLE users\n    ADD COLUMN email VARCHAR;\n```\n\n`02_add_email_to_users_table.sqlite.sql`\n\n```sql\n-- add email column to users table for SQLite\nALTER TABLE users\n    ADD COLUMN email VARCHAR;\n```\n\nIt should look like this:\n\n```\nmigrations/\n├─ 01_create_users_table.sql\n├─ 01_create_users_table.postgres.sql\n├─ 02_add_email_to_users_table.sql\n├─ 02_add_email_to_users_table.sqlite.sql\n```\n\nAlternatively you can also organize your migrations into dirver subdirectories:\n\n```\nmigrations/\n├─ postgres/\n│  ├─ 01_create_users_table.sql\n│  ├─ 02_add_email_to_users_table.sql\n├─ sqlite/\n│  ├─ 01_create_users_table.sql\n│  ├─ 02_add_email_to_users_table.sql\n```\n\nIn this case no `DRIVER` suffix is allowed in the migration file name.\n\n### Run migrations\n\nNow you can run the migrations in your Go code. Here is an example for SQLite:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"database/sql\"\n\t\"embed\"\n\t\"log\"\n\t\"log/slog\"\n\t\"time\"\n\n\t_ \"modernc.org/sqlite\"\n\n\t\"github.com/topi314/gomigrate\"\n\t\"github.com/topi314/gomigrate/drivers/sqlite\"\n)\n\n//go:embed migrations/*.sql\nvar migrations embed.FS\n\nfunc main() {\n\t// open database\n\tdb, err := sql.Open(\"sqlite\", \"database.db\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer db.Close()\n\n\t// create context with timeout\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\n\t// run migrations\n\tif err = gomigrate.Migrate(ctx, db, sqlite.New, migrations,\n\t\tgomigrate.WithDirectory(\"migrations\"), // set directory for migrations\n\t\tgomigrate.WithTableName(\"gomigrate\"),  // set custom table name for migrations\n\t\tgomigrate.WithLogger(slog.Default()),  // set custom logger\n\t); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// run your code\n}\n```\n\n## Examples\n\nYou can find examples under\n\n* sqlite: [_example](_examples/sqlite/main.go)\n* postgres: [_example](_examples/postgres/main.go)\n\n## Troubleshooting\n\nFor help feel free to open an issue.\n\n## Contributing\n\nContributions are welcomed but for bigger changes please first create an issue to discuss your intentions and ideas.\n\n## License\n\nDistributed under the [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE). See LICENSE for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftopi314%2Fgomigrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftopi314%2Fgomigrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftopi314%2Fgomigrate/lists"}