go-migration Documentation

Welcome to the official documentation for go-migration, 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.

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 and transaction support.
  • 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.
  • API Reference — Look up method signatures and usage details for all public APIs.

Quick Install

go get github.com/andrianprasetya/go-migration

Supported Databases

  • PostgreSQL
  • MySQL
  • SQLite