Documentation
Complete documentation for go-migration — a Laravel-inspired database migration and seeding system for Go.
Go Migration Documentation
Welcome to the official documentation for go-migration v1.2.0, a Laravel-inspired database migration and seeding system for Go.
go-migration provides a fluent, expressive API for managing database schema changes, seeding test data, and handling multiple database connections — all from your Go application or the command line.
See what's new in the latest release on the Changelog page. Highlights of v1.2.0: migrations are safe to run from several processes at once thanks to a cross-process lock, migrate:status --check works as a readiness gate, migrate:fresh works on every database, SQLite uses a pure-Go driver (no CGO), and the CLI entry point is now app.Run() from pkg/cli/app.
What You'll Find Here
- Getting Started — Install go-migration, run your first migration, and understand the project structure.
- Migrations — Define, register, run, and roll back schema migrations with batch tracking, transaction support, and a cross-process lock that makes concurrent runs safe.
- Schema Builder — Create and alter tables using a fluent API for columns, indexes, and foreign keys.
- Database Grammars — Understand how go-migration generates SQL for PostgreSQL, MySQL, and SQLite.
- Seeders & Factories — Populate your database with test or default data using seeders, factories, and the built-in faker.
- Connections — Configure and manage multiple named database connections with connection pooling.
- Hooks — Execute custom logic before and after migrations run.
- CLI — Use the command-line interface for all migration and seeding operations.
- Configuration — Set up go-migration with YAML, JSON, or environment variables.
- Framework Integration — Use go-migration with Gin, Echo, Fiber, or net/http.
- Error Handling — Diagnose and handle errors with typed error values and troubleshooting guidance.
- Package Reference — Look up method signatures and usage details for all public packages.
Quick Install
go get github.com/gopackx/go-migrationSupported Databases
- PostgreSQL (
github.com/lib/pq) - MySQL (
github.com/go-sql-driver/mysql) - SQLite (
modernc.org/sqlite, pure Go — builds withCGO_ENABLED=0)