golang-migrate

migrate

golang-migrate

A database migration tool written in Go, usable as a CLI or imported as a library, supporting a wide range of databases.

v4.20.1
Published at
Sep 9, 2026
18,953
Stars
6,317,167
Download
Synced at
15d ago

Latest release

v4.20.1Sep 9, 2026, 06:21 AM
Downloads slow? Switch the source anytime above

README

Project Overview

golang-migrate/migrate is a database migration tool written in Go. It can be used as a CLI tool or imported as a library into Go projects. The tool reads migrations from various sources and applies them in the correct order to the database.

Key Features

  • Supports multiple databases: PostgreSQL, MySQL, SQLite, MongoDB, Cassandra, ClickHouse, and more
  • Multiple migration sources: File system, GitHub, S3, Google Cloud Storage, etc.
  • CLI and library usage
  • Ensures migration logic is bulletproof; drivers are lightweight and don't assume user input
  • Database connection URLs

Target Audience

  • Go developers who need to manage database schema changes
  • Operations and database administrators
  • DevOps teams automating database migrations

Quick Start

  1. Install CLI: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
  2. Create a migration file: migrate create -ext sql -dir db/migrations -seq init
  3. Run migrations: migrate -database YOUR_DATABASE_URL -path db/migrations up
  4. Rollback migrations: migrate -database YOUR_DATABASE_URL -path db/migrations down

Core Advantages

  • Broad database support: Covers major relational and NoSQL databases
  • Flexible deployment: Works as a standalone CLI or Go library
  • Robust design: Database drivers stay lightweight; core logic ensures correctness
  • Active community: Continuously maintained and updated

System Requirements

  • OS: Cross-platform (Windows, macOS, Linux)
  • Architectures: x86_64, arm64
  • Additional Dependencies: Go (if used as a library)

Notes

  • Forked from mattes/migrate
  • Some database drivers are still in development (e.g., SQLite3, CrateDB)

Release history

Sort