Repolode
golang-migrate

golang-migrate/migrate

Go-based database migration tool with a CLI and library for applying ordered schema changes across many databases.

Stars
18,983
Forks
1,618
Open issues
492
Last commit
last month

What is it?

migrate reads versioned migration files from a source such as the local filesystem, S3, or GitHub, and applies them in order to a target database. Each migration is a pair of up and down files, so changes can be rolled forward or reverted. Database drivers handle the execution, while the core keeps ordering and state logic in one place.

It supports a broad set of databases, including PostgreSQL, MySQL and MariaDB, SQLite, MongoDB, Cassandra, Neo4j, Google Cloud Spanner, CockroachDB, ClickHouse and SQL Server. Migration sources include filesystem paths, io/fs, embedded binary data, GitHub, GitLab, Bitbucket, AWS S3 and Google Cloud Storage.

You can run it as a standalone command-line tool, use the official Docker image, or import it as a Go library. The library accepts your own database client and logger, and supports graceful stops to help avoid partial migrations.

Key features

  • 01Applies up and down migration files in version order.
  • 02Supports many databases, including PostgreSQL, MySQL, SQLite, MongoDB and Spanner.
  • 03Reads migrations from filesystem, embedded data, Git hosts and cloud storage.
  • 04Provides a CLI, a Docker image and a Go library.
  • 05Accepts an existing database client and custom logger when used as a library.

Use cases

  • Versioning schema changes for a Go service backed by PostgreSQL or MySQL.
  • Running migrations as a step in a CI/CD or container deployment pipeline.
  • Embedding migrations into a Go binary so they ship with the application.
  • Managing schema changes across several database engines from one tool.

Quick start

  1. 1

    Read the getting started guide and install the CLI as described there

  2. 2

    Run a migration with Docker, replacing the migration directory placeholder

    docker run -v {{ migration dir }}:/migrations --network host migrate/migrate -path=/migrations/ -database postgres://localhost:5432/database up 2

Things to know

  • The license is not clearly identified in the project metadata, so check the repository's license terms before use.

Topics

FAQ

What is migrate?
Go-based database migration tool with a CLI and library for applying ordered schema changes across many databases. migrate reads versioned migration files from a source such as the local filesystem, S3, or GitHub, and applies them in order to a target database. Each migration is a pair of up and down files, so changes can be rolled forward or reverted. Database drivers handle the execution, while the core keeps ordering and state logic in one place.
Is migrate free to use? What license does it have?
migrate is open source under the Other license. Check the license terms before using it in commercial products.
Is migrate still maintained?
Updated within 6 months. The last commit to migrate was on Sep 9, 2026.
What can I use migrate for?
Versioning schema changes for a Go service backed by PostgreSQL or MySQL. Running migrations as a step in a CI/CD or container deployment pipeline. Embedding migrations into a Go binary so they ship with the application. Managing schema changes across several database engines from one tool.
How do I install migrate?
Read the getting started guide and install the CLI as described there Run a migration with Docker, replacing the migration directory placeholder: docker run -v {{ migration dir }}:/migrations --network host migrate/migrate -path=/migrations/ -database postgres://localhost:5432/database up 2
Where can I get migrate?
The source code and installation instructions are on GitHub: https://github.com/golang-migrate/migrate

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects