v1.2.0 • Production Ready

Database migrations in Go, done right.

Struct-based migrations, a fluent schema builder, seeders, factories, and a single-binary CLI — all framework-agnostic. Ship confident schema changes across PostgreSQL, MySQL, and SQLite.

MIT LicensedPure Go · no CGOSingle binary CLI
migrations/2026_01_15_120000_4821_create_users.go
package migrations

type CreateUsers struct{}

func (m *CreateUsers) Up(s *schema.Builder) error {
    return s.Create("users", func(bp *schema.Blueprint) {
        bp.ID()
        bp.String("email", 255).Unique()
        bp.String("name", 255).Nullable()
        bp.Timestamps()
    })
}
QUICK START

From zero to your first migration in 60 seconds

Install the CLI, scaffold a migration, and run it. That's it.

1Install

Install the CLI with a single go install command.

bash
$ go install github.com/gopackx/go-migration/cmd/migrator@latest
 
2Scaffold

Generate a migration file with a sensible template.

bash
$ migrator make:migration create_users_table
 
3Migrate

Apply pending migrations to your database.

bash
$ migrator migrate
  ✔ 2026_01_15_120000_4821_create_users_table
Ready for more?Explore the full docs for factories, seeders, rollbacks, and advanced patterns.
Read the docs
WHY GO-MIGRATION

A modern take on Go database migrations

See how go-migration compares to the most popular alternatives in the Go ecosystem.

Featurego-migrationgolang-migrategoose
Struct-based migration API✓✕Partial
Fluent schema builder (no raw SQL)✓✕✕
Built-in seeders with dependency resolution✓✕✕
Generic factories with faker support✓✕✕
Transactional migrations with auto-rollback✓✓✓
Database drivers supportedPG · MySQL · SQLite10+ drivers6+ drivers
Framework agnostic (works with any *sql.DB)✓✓✓
CLI with migrate, rollback, fresh, scaffold✓Partial✓
Comparison based on publicly documented features as of April 2026. Missing something? Open a PR.
OPEN SOURCE · ACTIVELY MAINTAINED
WORKS WITH YOUR STACK

First-class support for PostgreSQL, MySQL and SQLite

PG

PostgreSQL

via lib/pq · tested on PostgreSQL 16 in CI

My

MySQL

via go-sql-driver · tested on MySQL 8 in CI

SL

SQLite

modernc.org/sqlite · pure Go, no CGO · ideal for tests