migrate

Database schema migrations for Go, usable as a CLI tool or an importable library with pluggable source and database drivers.

Library
Go
vv4.20.1
18,961 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
75 /100 Good
Development Activity 60
Maintenance 72
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
83 /100 Excellent
Architecture 85
Code Quality 82
Innovation 76
Learning Curve 88

migrate is a Go library and CLI for running database schema migrations. It reads versioned migration files from a source driver (local filesystem, embedded Go io/fs, S3, GitHub, GitLab, Bitbucket, or Google Cloud Storage) and applies them in order to a database driver, with support for 20+ databases including PostgreSQL, MySQL, SQLite, MongoDB, Cassandra, ClickHouse, and Google Cloud Spanner.

The core package stays deliberately “dumb”: migration logic — ordering, locking, dirty-state tracking, graceful stop — lives entirely in the top-level package, while source and database drivers implement narrow interfaces and register themselves via init(). This keeps individual drivers small and interchangeable, and lets teams embed migrate directly in their own Go binaries via WithInstance() using an already-open database connection, rather than shelling out to a separate CLI.

What You Get

  • Go library import (github.com/golang-migrate/migrate/v4) with New(), NewWithDatabaseInstance(), and WithInstance() constructors for embedding in Go programs
  • Standalone migrate CLI binary, also published as a Docker image, for running migrations outside your application code
  • Database drivers for 20+ engines, each implementing the same database.Driver interface so migration files stay portable across backends
  • Source drivers for local files, embedded Go io/fs, and remote GitHub, GitLab, Bitbucket, AWS S3, and Google Cloud Storage locations
  • Built-in dirty-state detection, advisory locking, and a Force() escape hatch for manual recovery after a failed migration

Common Use Cases

  • Running schema migrations automatically at application startup via WithInstance()
  • Applying migrations as a CI/CD deployment step using the CLI or the published Docker image
  • Keeping the same migration files portable across multiple supported database engines (e.g. Postgres in production, SQLite locally)
  • Storing and applying migrations from a remote source (S3, GitHub, GCS) instead of bundling files into every deploy artifact

Under The Hood

Architecture migrate centers on two narrow, well-documented interfaces — source.Driver and database.Driver — with all migration orchestration (version ordering, locking, dirty-state tracking, graceful stop via a GracefulStop channel) kept in the top-level migrate package so individual drivers stay “dumb” and interchangeable. Drivers self-register into a package-level map via init(), and the CLI binary (cmd/migrate, backed by internal/cli) composes only the drivers selected through Go build tags at compile time, keeping any given binary’s dependency footprint scoped to the databases and sources it actually needs. This registry-plus-interface pattern is what lets 20+ database drivers and 10+ source drivers share one core without the core knowing any backend specifics.

Tech Stack Built for Go 1.25+ using the standard database/sql package alongside native/CGo-free drivers per backend (lib/pq and jackc/pgx v4/v5 for Postgres, go-sql-driver/mysql, mattn/go-sqlite3 and modernc.org/sqlite for SQLite, gocql for Cassandra/ScyllaDB, mongo-driver for MongoDB, Google Cloud Spanner/Storage and AWS SDK clients for cloud backends, plus go-github, go-gitlab, and go-bitbucket for remote migration sources). The Makefile drives CGO_ENABLED=0 cross-platform builds gated by SOURCE/DATABASE build-tag lists, and the project ships Dockerfiles for both local and CI image builds plus prebuilt CLI binaries for major platforms.

Code Quality The repository carries roughly 50 _test.go files, including shared database/testing and source/testing harnesses that every driver’s test suite calls into, so new drivers get the same correctness checks (Open/Close/Lock/Run behavior) without reimplementing them. Errors are explicit sentinel or typed values (ErrDirty, ErrLocked, ErrShortLimit) rather than swallowed, a .golangci.yml enforces lint rules, and GitHub Actions CI (ci.yaml) runs the suite on each change.

API Design The public surface is small and consistent: New()/NewWithDatabaseInstance()/WithInstance() constructors, then Up()/Down()/Steps()/Migrate()/Force() as the entire verb set, mirrored 1:1 by the CLI’s up/down/goto/force subcommands. Getting started with an existing *sql.DB requires only a WithInstance() call and a blank import for the chosen driver package — no config files or generated code — which keeps the boilerplate to embed migrate in an existing service low.

Used by 15 apps in this directory

Vue
43%
MIT

Alexandrie

Collaboration · Knowledge Management · Note Taking

2,797

The open-source, offline-first Notion, Obsidian & Confluence alternative with multi-tenant teams, OIDC/SSO, and one-command Docker deployment.

View details
85
Repo Health
73
Technical
74
Dependency
Built with
Vue 43%
TypeScript 41%
Go 13%
Updated 2 weeks ago
Go
75%
AGPL 3.0

Coder

Code Editors · Developer Tools · Devops

16,920

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
91
Repo Health
90
Technical
65
Dependency
Built with
Go 75%
TypeScript 23%
Updated today
Go
75%
Other

Flipt

Developer Tools · Devops

4,916

Git-native feature flag platform that stores, versions, and deploys feature toggles directly in your own Git repositories with no external database required.

View details
90
Repo Health
83
Technical
68
Dependency
Built with
Go 75%
TypeScript 24%
Updated yesterday
Go
62%
Apache 2.0

Harness Open Source

Code Editors · Developer Tools · Devops

38,509

A unified open source DevOps platform combining Git hosting, CI/CD pipelines, cloud development environments, and artifact registries in a single self-hosted system.

View details
90
Repo Health
79
Technical
64
Dependency
Built with
Go 62%
TypeScript 33%
Updated yesterday
TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,384

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
71
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 1 weeks ago
Go
67%
MIT

hoop

Monitoring · Security

831

A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.

View details
86
Repo Health
80
Technical
64
Dependency
Built with
Go 67%
Clojure 15%
JavaScript 11%
Updated today
TypeScript
52%
Other

Mattermost

Collaboration · Devops · Team Chat

39,306

Open core, self-hosted team collaboration with chat, AI agents, voice calling, and deep DevOps integrations — all under your control.

View details
96
Repo Health
87
Technical
65
Dependency
Built with
TypeScript 52%
Go 40%
Updated yesterday
Go
68%
MIT

nginx ignition

Developer Tools · Devops

2,145

A modern web UI for nginx that eliminates config file editing with visual virtual hosts, SSL automation, Docker integrations, and real-time traffic analytics.

View details
74
Repo Health
80
Technical
70
Dependency
Built with
Go 68%
TypeScript 29%
Updated 2 days ago
Go
78%
Apache 2.0

OpenMeter

Developer Tools · Invoicing Finance

2,377

Open-source metering and billing engine for AI, agentic, and DevTool monetization — ingest usage events in real time and turn them into accurate invoices automatically.

View details
87
Repo Health
81
Technical
65
Dependency
Built with
Go 78%
TypeScript 17%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers