migrate

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package migrate provides database migration helpers for containerized databases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMigration

func CreateMigration(dir, name string) (string, error)

CreateMigration creates a new migration file pair (up and down).

func ForceVersion

func ForceVersion(ctx context.Context, db *sql.DB, version string, opts ...migrate.Option) error

ForceVersion sets the schema version without running migrations.

func ListMigrations

func ListMigrations(dir string) ([]migrate.Migration, error)

ListMigrations returns all available migrations.

Types

type Option

type Option func(*Runner)

Option configures the Runner.

func WithDir

func WithDir(dir string) Option

WithDir sets the migrations directory.

func WithTableName

func WithTableName(name string) Option

WithTableName sets the migration tracking table name.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the timeout for each migration step.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner handles database migrations for containerized databases.

func NewRunner

func NewRunner(db *sql.DB, opts ...Option) *Runner

NewRunner creates a new migration runner.

func (*Runner) Down

func (r *Runner) Down(ctx context.Context, steps int) error

Down rolls back the last N migrations. If steps <= 0, rolls back all.

func (*Runner) Status

func (r *Runner) Status(ctx context.Context) ([]migrate.Status, error)

Status returns the status of all migrations.

func (*Runner) Up

func (r *Runner) Up(ctx context.Context) error

Up runs all pending up migrations.

Jump to

Keyboard shortcuts

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