migration

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migration

type Migration struct {
	Version    uint
	Identifier string
	Up         []byte
	Down       []byte
}

Migration holds both directions for a single version.

func LoadAll

func LoadAll(src source.Driver, logger *slog.Logger) ([]Migration, error)

LoadAll reads all migrations from the provided source.Driver in ascending version order. Caller is responsible for closing the source driver.

type Runner

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

Runner coordinates applying migrations using a state store and executor.

func NewRunner

func NewRunner(store state.Store, exec executor.Executor, registry *schema.Registry, logger *slog.Logger, dryRun bool, migrations []Migration) *Runner

NewRunner constructs a Runner with parsed migrations.

func (*Runner) Close

func (r *Runner) Close() error

Close releases resources on the store, if any.

func (*Runner) Down

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

Down rolls back a number of migrations (default 1 if steps<=0).

func (*Runner) Migrate

func (r *Runner) Migrate(ctx context.Context, target uint) error

Migrate moves to the target version, applying up or down as needed.

func (*Runner) Status

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

Status reports the current applied version and the pending migration versions.

func (*Runner) Up

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

Up applies pending migrations up to the optional target version. If target is nil, all pending migrations are applied.

Jump to

Keyboard shortcuts

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