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

migrations

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Up

func Up(ctx context.Context, options ...UpOption) error

Up applies every pending file, in one transaction per file.

Types

type Entry

type Entry struct {
	Version   string
	Name      string
	State     State
	AppliedAt time.Time
}

func Status

func Status(ctx context.Context, options ...StatusOption) ([]Entry, error)

Status reads the state of each migration file and of each history row.

type Option

type Option interface {
	UpOption
	StatusOption
}

Option configures every function of this package.

func WithDatabase

func WithDatabase(driver dbdiffdrivers.DriverName, url string) Option

WithDatabase names the database that receives the migrations. An empty driver value starts the detection of the engine from the url value, which holds a SQLite path or a PostgreSQL connection string.

func WithDirectory

func WithDirectory(directory string) Option

WithDirectory names the directory that holds the migration files.

func WithOutput

func WithOutput(output io.Writer) Option

WithOutput names the writer that receives one progress line per applied file. Without this option the lines go away.

func WithSchema

func WithSchema(schema string) Option

WithSchema names the PostgreSQL schema. Without this option the search path of the connection string applies.

type State

type State string
const (
	StateApplied    State = "applied"
	StatePending    State = "pending"
	StateChanged    State = "changed"
	StateMissing    State = "missing"
	StateOutOfOrder State = "out of order"
	StateDirty      State = "dirty"
)

type StatusOption

type StatusOption interface {
	// contains filtered or unexported methods
}

StatusOption configures Status.

type UpOption

type UpOption interface {
	// contains filtered or unexported methods
}

UpOption configures Up.

func WithToVersion

func WithToVersion(version string) UpOption

WithToVersion stops Up after the file with the given version.

Jump to

Keyboard shortcuts

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