go-migrations

command
v3.30.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

SQL + Go migrations

This example: Custom goose binary with built-in Go migrations

$ go build -o goose-custom *.go
$ ./goose-custom sqlite3 ./foo.db status
    Applied At                  Migration
    =======================================
    Pending                  -- 00001_create_users_table.sql
    Pending                  -- 00002_rename_root.go
    Pending                  -- 00003_add_user_no_tx.go

$ ./goose-custom sqlite3 ./foo.db up
    OK   00001_create_users_table.sql (711.58µs)
    OK   00002_rename_root.go (302.08µs)
    OK   00003_add_user_no_tx.go (648.71µs)
    goose: no migrations to run. current version: 3

$ ./goose-custom sqlite3 ./foo.db status
    Applied At                  Migration
    =======================================
    00001_create_users_table.sql
    00002_rename_root.go
    00003_add_user_no_tx.go

Best practice: Split migrations into a standalone package

  1. Move main.go into your cmd/ directory

  2. Rename package name in all *_.go migration files from main to migrations.

  3. Import this migrations package from your custom cmd/main.go file:

    import (
        // Invoke init() functions within migrations pkg.
        _ "github.com/pressly/goose/example/migrations-go"
    )
    

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL