migrator

package
v0.0.0-...-768bafe Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CliCmd

func CliCmd(l logger, fs embed.FS, migrationsPath string, opsmigrations DataMigrations) *cli.Command

CliCmd returns a cli.Command for managing database migrations.

func GetCurrentSchemaVersion

func GetCurrentSchemaVersion(db *sql.DB) (int, error)

GetCurrentSchemaVersion gets the current schema version from the database

func GetMaxVersion

func GetMaxVersion(path string) (int, error)

Types

type DataMigration

type DataMigration struct {
	Version int
	// Hooks
	BeforeUpFn   func(context.Context, *sql.Tx) error
	AfterUpFn    func(context.Context, *sql.Tx) error
	BeforeDownFn func(context.Context, *sql.Tx) error
	AfterDownFn  func(context.Context, *sql.Tx) error
}

type DataMigrations

type DataMigrations []DataMigration

type Service

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

func New

func New(logger logger, fs embed.FS, migrationsPath string, opsmigrations DataMigrations) *Service

func (*Service) MigrateDown

func (m *Service) MigrateDown(ctx context.Context, dbPath string) error

MigrateDown rolls back the last applied migration

func (*Service) MigrateUpAll

func (m *Service) MigrateUpAll(ctx context.Context, dbPath string) error

MigrateUpAll runs all pending database migrations

Jump to

Keyboard shortcuts

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