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.
package migrations
type CreateUsers struct{}
func (m *CreateUsers) Up(s *schema.Builder) {
s.Create("users", func(t *schema.Table) {
t.ID()
t.String("email").Unique()
t.String("name").Nullable()
t.Timestamps()
})
}Everything you need to ship migrations
A Laravel-inspired workflow, rebuilt from scratch for idiomatic Go. No ORM lock-in, no magic — just fast, predictable schema management.
Struct-Based Migrations
Define migrations as Go structs with explicit Up and Down methods. Type-safe, testable, and plays nicely with your existing codebase.
Fluent Schema Builder
Chainable API for creating tables, columns, indexes, and foreign keys. Write expressive schemas without touching raw SQL.
Seeders & Factories
Populate databases with realistic test data using composable factories and deterministic seeders. Perfect for dev and CI.
CLI Commands
A single-binary CLI for migrate, rollback, refresh, scaffold, and more. Artisan-style ergonomics with Go-native performance.
Multi-Database Support
First-class drivers for PostgreSQL, MySQL/MariaDB, and SQLite — with dialect-aware SQL generation and transactional DDL where supported.
Framework Agnostic
Drop it into any Go project — Gin, Echo, Fiber, Chi, or plain net/http. No framework coupling, no global state, no init surprises.
From zero to your first migration in 60 seconds
Install the CLI, scaffold a migration, and run it. That's it.
Install the CLI with a single go install command.
$ go install github.com/gopackx/go-migration@latest
Generate a migration file with a sensible template.
$ go-migration make:migration create_users_table
Apply pending migrations to your database.
$ go-migration migrate ✔ 001_create_users_table
A modern take on Go database migrations
See how go-migration compares to the most popular alternatives in the Go ecosystem.
| Feature | go-migration | golang-migrate | goose |
|---|---|---|---|
| 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 supported | PG · MySQL · SQLite | 10+ drivers | 6+ drivers |
| Framework agnostic (works with any *sql.DB) | ✓ | ✓ | ✓ |
| CLI with migrate, rollback, fresh, scaffold | ✓ | Partial | ✓ |
First-class support for every major database
PostgreSQL
9.6 → latest · JSON, arrays, CTE
MySQL / MariaDB
5.7 → latest · InnoDB tuned
SQLite
3.8+ · Ideal for tests & embedded
SQL Server
2017+ · Windows & Linux drivers
Ready to ship faster migrations?
Join thousands of Go developers managing their database schemas with confidence. Read the docs, explore examples, or drop a star on GitHub.