{"id":18267564,"url":"https://github.com/tomasruud/up","last_synced_at":"2026-04-30T15:31:29.845Z","repository":{"id":170589182,"uuid":"645651493","full_name":"tomasruud/up","owner":"tomasruud","description":"A simple, zero dependency, database agnostic, migration tool for Go projects","archived":false,"fork":false,"pushed_at":"2023-06-01T08:10:47.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T02:31:40.231Z","etag":null,"topics":["database","go","golang","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomasruud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-05-26T06:13:30.000Z","updated_at":"2023-05-29T09:12:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e6cbaa5-f1ef-428e-a99e-1f5a55b89ac0","html_url":"https://github.com/tomasruud/up","commit_stats":null,"previous_names":["tomasruud/up"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tomasruud/up","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasruud%2Fup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasruud%2Fup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasruud%2Fup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasruud%2Fup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomasruud","download_url":"https://codeload.github.com/tomasruud/up/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasruud%2Fup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32469344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"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","go","golang","migration-tool"],"created_at":"2024-11-05T11:27:52.776Z","updated_at":"2026-04-30T15:31:29.831Z","avatar_url":"https://github.com/tomasruud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Up\n\nA simple, zero dependency, database agnostic, migration library for Go projects.\n\nUp, as the name suggests, only supports migrations in a single direction. This means that a migration can never be rolled back. If you need to revert a change, you have to append a new migration that reverts your previous change. If you need to be able to migrate down, this library is probably not for you.\n\nCheck out the complete docs at https://go.dev/pkg/github.com/tomasruud/up\n\n## Usage\n### Minimal\nBelow is a minimal example on how migrations for a SQLite database could be done.\n\n```go\npackage main\n\nimport (\n\t\"database/sql\"\n\t\"log\"\n\n\t\"github.com/tomasruud/up\"\n\t_ \"modernc.org/sqlite\"\n)\n\nfunc main() {\n\tdb, _ := sql.Open(\"sqlite\", \":memory:\")\n\n\tmigrator := up.Migrator{\n\t\tStateStore: up.SQLiteStore{},\n\t\tMigrations: []up.Migration{\n\t\t\tfunc(tx *sql.Tx) error {\n\t\t\t\t_, err := tx.Exec(`create table users(id text primary key)`)\n\t\t\t\treturn err\n\t\t\t},\n\n\t\t\tfunc(tx *sql.Tx) error {\n\t\t\t\t_, err := tx.Exec(`alter table users add column name text`)\n\t\t\t\treturn err\n\t\t\t},\n\t\t},\n\t}\n\n\tif err := migrator.Migrate(db); err != nil {\n\t\tlog.Fatalf(\"Unable to run migrations: %v\", err)\n\t}\n\n\tlog.Println(\"Migrations done\")\n}\n\n```\n\n### Full\nBelow is a full example on how this library could be used, including using callback hooks for doing logging. This example uses the provided `StateStore` for SQLite, but you are free to make your own implementation that suit your needs.\n\n```go\npackage main\n\nimport (\n\t\"database/sql\"\n\t\"log\"\n\n\t\"github.com/tomasruud/up\"\n\t_ \"modernc.org/sqlite\"\n)\n\nfunc main() {\n\tdb, _ := sql.Open(\"sqlite\", \":memory:\")\n\n\tmigrations := []up.Migration{\n\t\tfunc(tx *sql.Tx) error {\n\t\t\t_, err := tx.Exec(`create table users(id text primary key)`)\n\t\t\treturn err\n\t\t},\n\n\t\tfunc(tx *sql.Tx) error {\n\t\t\t_, err := tx.Exec(`alter table users add column name text`)\n\t\t\treturn err\n\t\t},\n\t}\n\n\tmigrator := up.Migrator{\n\t\tStateStore: up.SQLiteStore{},\n\t\tMigrations: migrations,\n\n\t\tOnSetupComplete: func(start int, last *int) {\n\t\t\tif last == nil {\n\t\t\t\tlog.Printf(\"Migrations initialized, no migrations have run\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlog.Printf(\"Migrations initialized, latest migration is %d\", *last)\n\t\t},\n\n\t\tOnMigrationDone: func(current int, start int) {\n\t\t\tlog.Printf(\"Migration %d/%d done\", current+1+start, len(migrations)-start)\n\t\t},\n\t}\n\n\tif err := migrator.Migrate(db); err != nil {\n\t\tlog.Fatalf(\"Unable to run migrations: %v\", err)\n\t}\n\n\tlog.Println(\"Migrations done\")\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasruud%2Fup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomasruud%2Fup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasruud%2Fup/lists"}