migrate

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

Library
Go
vv4.19.1
18,864stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
74/100Good
Development Activity68
Maintenance60
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture85
Code Quality82
Innovation76
Learning Curve88

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 14 apps in this directory

Go
75%
AGPL 3.0

Coder

Devops · Developer Tools · Code Editors

14,299

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

View details
93
Repo Health
90
Technical
69
Dependency
Built with
Go75%
TypeScript23%
Updated today
Go
73%
Other

Flipt

Devops · Developer Tools

4,884

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
89
Repo Health
83
Technical
70
Dependency
Built with
Go73%
TypeScript26%
Updated yesterday
Go
61%
Apache 2.0

Harness Open Source

Developer Tools · Devops · Code Editors

38,169

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
89
Repo Health
79
Technical
64
Dependency
Built with
Go61%
TypeScript34%
Updated 2 days ago
TypeScript
71%
Other

highlight.io

Developer Tools · Analytics · Monitoring

9,373

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
70
Repo Health
78
Technical
65
Dependency
Built with
TypeScript71%
Go16%
Updated 1 weeks ago
Go
58%
MIT

hoop

Security · Monitoring

805

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
85
Repo Health
80
Technical
65
Dependency
Built with
Go58%
Clojure19%
JavaScript14%
Updated 2 days ago
TypeScript
51%
Other

Mattermost

Team Chat · Collaboration · Devops

38,940

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
TypeScript51%
Go40%
Updated yesterday
Go
67%
MIT

nginx ignition

Developer Tools · Devops

2,136

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
67
Repo Health
80
Technical
76
Dependency
Built with
Go67%
TypeScript30%
Updated today
Go
78%
Apache 2.0

OpenMeter

Invoicing Finance · Developer Tools

2,236

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
86
Repo Health
81
Technical
66
Dependency
Built with
Go78%
TypeScript17%
Updated 2 days ago
Go
93%
MIT

Plandex

AI Code Assistants

15,598

An open-source, terminal-based AI coding agent built for large tasks and real codebases — with its own version control for plans, a 2M-token effective context window, and self-hosted or cloud deployment.

View details
49
Repo Health
70
Technical
68
Dependency
Built with
Go93%
Updated 11 months ago

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

Search