Database migrations as a CLI and Go library
open sourceMITfree
golang-migrate (migrate) runs database migrations, as a command-line tool or a library imported into a Go program. It reads migrations from sources such as local files, embedded files, GitHub, S3 and Google Cloud Storage and applies them in order to more than twenty databases, including PostgreSQL, MySQL and MariaDB, SQLite, SQL Server, MongoDB, ClickHouse, CockroachDB, Cassandra, Spanner and Redshift, each through a deliberately simple driver that fails rather than guesses. Databases are given as connection URLs. It was forked from mattes/migrate and is MIT licensed.
Ways to install
Package managers
Problems it solves
- run versioned SQL migrations against Postgres when my Go service starts
- a migration CLI that works the same for MySQL and Postgres in CI
- embed migration files in my Go binary and apply them on deploy
Features
- CLI and Go library
- drivers for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB, ClickHouse and more
- migration sources: files, embedded files, GitHub, S3, GCS
- separate up and down migration files
- database given as a connection URL
Alternatives
The same job
These do what golang-migrate does.
- Flyway Versioned SQL database migrations for 50+ databases, open source with Redgate's enterprise editions
- dbmate A lightweight, framework-agnostic database migration tool for plain SQL migrations
- Atlas Database schema as code: plan, lint, test and apply schema migrations, like Terraform for databases
- pgroll Zero-downtime, reversible schema migrations for Postgres
- Reshape An easy-to-use, zero-downtime schema migration tool for Postgres
- goose (database migrations) Database migration tool for SQL files and Go functions