up

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RunTargetLatest     = -1
	RevertTargetInitial = 0
)

Variables

View Source
var (
	ErrLocked          = errors.New("version store is locked for writing")
	ErrInitialVersion  = errors.New("initial version is current")
	ErrVersionNotFound = errors.New("version not found")
)

Functions

This section is empty.

Types

type FuncLoader

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

func NewFuncLoader

func NewFuncLoader(migrations ...*Migration) *FuncLoader

func (*FuncLoader) Load

func (l *FuncLoader) Load(ctx context.Context) ([]*Migration, error)

type Loader

type Loader interface {
	Load(context.Context) ([]*Migration, error)
}

type Migration

type Migration struct {
	Version    int64
	Name       string
	RunFunc    func(context.Context, *sql.DB) error
	RevertFunc func(context.Context, *sql.DB) error
}

func (*Migration) Revert

func (m *Migration) Revert(ctx context.Context, db *sql.DB) error

func (*Migration) Run

func (m *Migration) Run(ctx context.Context, db *sql.DB) error

type Migrator

type Migrator struct {
	Store   Store
	Sources []*Migration
	LogW    io.Writer
	DebugW  io.Writer

	HoldLockOnFailure bool
}

func (*Migrator) Revert

func (m *Migrator) Revert(ctx context.Context, to int64) (err error)

func (*Migrator) Run

func (m *Migrator) Run(ctx context.Context, to int64) (err error)

type Store

type Store interface {
	DB() *sql.DB
	Init(context.Context) error
	Lock(context.Context) error
	Release(context.Context) error
	Version(context.Context) (int64, error)
	Insert(context.Context, int64) error
	Remove(context.Context, int64) error
}

Directories

Path Synopsis
stores

Jump to

Keyboard shortcuts

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