Versions in this module Expand all Collapse all v0 v0.1.1 Sep 8, 2026 v0.1.0 Aug 31, 2026 Changes in this version + var ErrAlreadyApplied = errors.New("migration: already applied") + var ErrChecksumMismatch = errors.New("migration: checksum mismatch, applied migration was modified") + var ErrDirtyState = errors.New("migration: dirty migration state, manual intervention required") + var ErrDuplicateVersion = errors.New("migration: duplicate migration version") + var ErrLocked = errors.New("migration: could not acquire migration lock") + var ErrNoMigrations = errors.New("migration: no migrations found") + var ErrNotApplied = errors.New("migration: not applied") + var ErrOutOfOrder = errors.New("migration: out-of-order migration") + func Checksum(content []byte) string + type DB interface + ExecContext func(ctx context.Context, query string, args ...any) (sql.Result, error) + QueryContext func(ctx context.Context, query string, args ...any) (*sql.Rows, error) + QueryRowContext func(ctx context.Context, query string, args ...any) *sql.Row + type Direction int + const Down + const Up + func (d Direction) String() string + type Engine struct + func NewEngine(db DB, provider Provider, entries []Entry) (*Engine, error) + func (e *Engine) Fresh(ctx context.Context) (Result, error) + func (e *Engine) Plan(ctx context.Context, dir Direction, steps int) ([]Entry, error) + func (e *Engine) Reset(ctx context.Context) (Result, error) + func (e *Engine) Rollback(ctx context.Context, steps int) (Result, error) + func (e *Engine) Status(ctx context.Context) ([]StatusEntry, error) + func (e *Engine) Up(ctx context.Context, steps int) (Result, error) + func (e *Engine) Validate(ctx context.Context) error + type Entry struct + Checksum string + func Load(fsys fs.FS, reg *Registry) ([]Entry, error) + func LoadSQLMigrations(fsys fs.FS) ([]Entry, error) + type HistoryStore interface + Begin func(ctx context.Context, db DB, version uint64, name, checksum string, batch int) error + Complete func(ctx context.Context, db DB, version uint64, executionTime time.Duration) error + EnsureTable func(ctx context.Context, db DB) error + List func(ctx context.Context, db DB) ([]Record, error) + Remove func(ctx context.Context, db DB, version uint64) error + type Locker interface + Lock func(ctx context.Context) error + Unlock func(ctx context.Context) error + type Migration interface + Down func(ctx context.Context, db DB) error + Name func() string + Up func(ctx context.Context, db DB) error + Version func() uint64 + type Provider interface + History func() HistoryStore + Locker func(db DB) Locker + Name func() string + SupportsTransactionalDDL func() bool + type Record struct + AppliedAt time.Time + Batch int + Checksum string + Dirty bool + ExecutionTime time.Duration + Name string + Version uint64 + type Registry struct + func NewRegistry() *Registry + func (r *Registry) All() []Entry + func (r *Registry) Register(m Migration, checksum string) error + type Result struct + Batch int + Executed []Record + type StatusEntry struct + Applied bool + AppliedAt time.Time + Batch int + Dirty bool + Name string + Version uint64 + type Tx interface + Commit func() error + Rollback func() error + type TxCapableDB interface + BeginTx func(ctx context.Context, opts *sql.TxOptions) (Tx, error)