Migrate applies versioned up and down SQL (and driver-specific) changes to many databases from local or remote sources. Use it as a command-line tool or embed the Go package in your application.
Overview
Migrate is a database migration system written in Go. It reads migration files from configured sources, orders them, and runs them against a database through pluggable drivers. The design keeps drivers minimal while central logic handles sequencing and safety.
Supported databases include PostgreSQL (including PGX variants), MySQL and MariaDB, SQLite, MongoDB, Cassandra or ScyllaDB, CockroachDB, ClickHouse, Microsoft SQL Server, Google Cloud Spanner, Neo4j, and others. Connections use driver-specific URL strings with escaping rules for reserved characters.
Migration sources can be a local filesystem or remote stores such as GitHub, GitLab, Bitbucket, AWS S3, and Google Cloud Storage. Each migration defines an up step and a down step. The CLI wraps the library, handles interrupt signals gracefully, and avoids config-file magic; container-based usage has separate documentation.
As a Go library, the API is stable for current major releases. It supports graceful shutdown through a channel, accepts a custom logger, streams via io.Reader for lower memory use, and is thread-safe without goroutine leaks. The codebase was forked from mattes/migrate; migradaptor helps when moving from other migration tools.
Key features
- Ordered up and down migrations
- Many SQL and NoSQL database drivers
- Filesystem and remote migration sources
- URL-based database connections
- Go library with stable API
- CLI with graceful interrupt handling
- Documented Docker usage
- Thread-safe embedded runner
Use cases
- Versioning PostgreSQL schema in CI
- Shipping migrations from object storage
- Embedding migrations in Go services
- Running repeatable database upgrades
- Coordinating rollbacks with down files