stmigrate

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultExecutorFactory

func SetDefaultExecutorFactory(f func() executor.Executor)

SetDefaultExecutorFactory overrides the default executor factory (intended for tests).

Types

type Config

type Config struct {
	SourceURL string
	Store     state.Store
	Executor  executor.Executor
	Logger    *slog.Logger
	DryRun    bool
	Registry  *schema.Registry
	// Optional DB parameters to let the SDK build a dedicated migrate driver.
	DB              *sql.DB
	DBDriver        string // postgres | mysql | sqlite3
	MigrationsTable string
	// SkipCloseDB prevents the runner from closing the store/driver when using a shared DB (primarily for sqlite3).
	SkipCloseDB bool
}

Config drives construction of a Runner instance.

type Runner

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

Runner is the public API surface for applying migrations.

func New

func New(cfg Config) (*Runner, error)

New constructs a Runner using the provided configuration. If Store is nil, an in-memory store is used. If Executor is nil, SuperTokens is used. If Registry is nil, the default schema registry is used.

func NewWithWrappedDatabase added in v0.2.4

func NewWithWrappedDatabase(cfg Config, driverName string, db *sql.DB, tableName string) (*Runner, error)

NewWithWrappedDatabase builds a migrate driver from the provided *sql.DB and driver name, then constructs a Runner. The driver is built with a dedicated connection so closing the runner will not close the caller's DB pool.

func NewWithWrappedDriver added in v0.2.4

func NewWithWrappedDriver(cfg Config, driver database.Driver) (*Runner, error)

NewWithWrappedDriver wraps an existing migrate database.Driver and constructs a Runner.

func (*Runner) Close

func (r *Runner) Close() error

func (*Runner) Down

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

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)

func (*Runner) Up

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

Jump to

Keyboard shortcuts

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