migrations

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, db adapter.DatabaseConn, opts MigrationOptions, logger *slog.Logger) (err error)

Migrate performs database migrations.

Types

type MigrationFn

type MigrationFn = func(ctx context.Context) error

type MigrationOptions

type MigrationOptions struct {
	// List of migrations to execute.
	// Each item is a function that receives a context and the database connection, and can execute queries.
	Migrations []MigrationFn

	// EnsureMetadataTable ensures that the metadata table exists.
	EnsureMetadataTable func(ctx context.Context) error

	// GetVersionQuery is the query to execute to load the latest migration version.
	GetVersionQuery string

	// UpdateVersionQuery is a function that returns the query to update the migration version, and the arg.
	UpdateVersionQuery func(version string) (string, any)
}

MigrationOptions contains options for the Migrate function.

type MigrationTeardownFn

type MigrationTeardownFn = func() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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