Help us shape the future of Go! Take the 2026 Go Developer Survey

migrate

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package migrate provides lightweight database migration helpers based on pressly/goose/v3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDBVersion

func GetDBVersion(ctx context.Context, db *sql.DB, driver string, opts ...Option) (int64, error)

GetDBVersion returns the current database version.

func GetStatus

func GetStatus(ctx context.Context, db *sql.DB, driver string, fsys fs.FS, dir string, opts ...Option) ([]*goose.MigrationStatus, error)

GetStatus returns the current migration status list.

func NewProvider

func NewProvider(db *sql.DB, driver string, fsys fs.FS, dir string, opts ...Option) (*goose.Provider, error)

NewProvider creates a new goose.Provider instance with isolated state.

func RunDown

func RunDown(ctx context.Context, db *sql.DB, driver string, dir string, opts ...Option) error

RunDown rolls back the most recently applied migration from a local filesystem directory.

func RunDownFS

func RunDownFS(ctx context.Context, db *sql.DB, driver string, fsys fs.FS, dir string, opts ...Option) error

RunDown rolls back the most recently applied migration from a given fs.FS.

func RunUp

func RunUp(ctx context.Context, db *sql.DB, driver string, dir string, opts ...Option) error

RunUp executes all pending migrations from a local filesystem directory.

func RunUpFS

func RunUpFS(ctx context.Context, db *sql.DB, driver string, fsys fs.FS, dir string, opts ...Option) error

RunUpFS executes all pending migrations from a given fs.FS (e.g. embed.FS or os.DirFS).

func ToGooseDialect

func ToGooseDialect(driver string) (goose.Dialect, error)

ToGooseDialect maps framework database driver names (mysql, postgres, sqlite) to standard goose.Dialect.

Types

type Option

type Option func(*options)

Option defines a functional option for configuring migration executions.

func WithTableName

func WithTableName(table string) Option

WithTableName configures a custom table name for tracking migration versions (default: "goose_db_version").

Jump to

Keyboard shortcuts

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