Versions in this module Expand all Collapse all v1 v1.0.0 Aug 25, 2026 Changes in this version + var ErrBackendResult = errors.New("invalid migration backend result") + var ErrBaselineExists = errors.New("migration baseline already exists") + var ErrBaselineMismatch = errors.New("schema does not match reviewed baseline") + var ErrBaselineUnsupported = errors.New("migration backend does not support baselines") + var ErrBaselineVersionConflict = errors.New("go migration conflicts with baseline version") + var ErrChecksumMismatch = errors.New("migration checksum mismatch") + var ErrDeletedMigration = errors.New("applied migration was deleted") + var ErrDirty = errors.New("dirty migration history") + var ErrDuplicateVersion = errors.New("duplicate migration version") + var ErrEmptyUpSQL = errors.New("migration up SQL is empty") + var ErrInvalidBaseline = errors.New("invalid schema baseline") + var ErrInvalidChecksum = errors.New("invalid migration checksum") + var ErrInvalidEncoding = errors.New("invalid migration encoding") + var ErrInvalidFilename = errors.New("invalid migration filename") + var ErrInvalidFormat = errors.New("invalid migration format") + var ErrInvalidName = errors.New("invalid migration name") + var ErrInvalidRecord = errors.New("invalid migration record") + var ErrInvalidRecovery = errors.New("invalid dirty migration recovery") + var ErrInvalidRunner = errors.New("invalid migration runner") + var ErrInvalidSource = errors.New("invalid migration source") + var ErrInvalidTarget = errors.New("invalid migration target") + var ErrInvalidTransactionMode = errors.New("invalid transaction mode") + var ErrInvalidVersion = errors.New("invalid migration version") + var ErrIrreversible = errors.New("migration is irreversible") + var ErrNoDirtyMigration = errors.New("dirty migration not found") + var ErrRecoveryConflict = errors.New("multiple dirty migrations require recovery") + var ErrRecoveryMismatch = errors.New("dirty migration recovery identity mismatch") + var ErrRecoveryUnsupported = errors.New("migration backend does not support recovery") + var ErrRenamedMigration = errors.New("applied migration was renamed") + var ErrReorderedHistory = errors.New("migration history was reordered") + var ErrUnexpectedSourceEntry = errors.New("unexpected migration source entry") + type Action uint8 + const ActionApply + const ActionRollback + type Backend interface + Acquire func(context.Context) (Session, error) + type Baseline struct + func NewBaseline(version Version, name string, fingerprint Checksum) (Baseline, error) + func (baseline Baseline) Fingerprint() Checksum + func (baseline Baseline) Name() string + func (baseline Baseline) Version() Version + type Checksum struct + func ChecksumData(canonical []byte) Checksum + func ParseChecksum(value string) (Checksum, error) + func (checksum Checksum) GoString() string + func (checksum Checksum) String() string + type Event struct + func (event Event) Duration() time.Duration + func (event Event) Err() error + func (event Event) Operation() Operation + func (event Event) Phase() Phase + func (event Event) Version() Version + type FSSource struct + func NewFSSource(sourceFS fs.FS, root string) (*FSSource, error) + func (source *FSSource) Load(ctx context.Context) ([]Migration, error) + type Migration struct + func NewMigration(version Version, name string, transactionMode TransactionMode, upSQL string, ...) (Migration, error) + func (migration Migration) Checksum() Checksum + func (migration Migration) DownSQL() string + func (migration Migration) Name() string + func (migration Migration) TransactionMode() TransactionMode + func (migration Migration) UpSQL() string + func (migration Migration) Version() Version + type Observer interface + Observe func(context.Context, Event) + type Operation uint8 + const OperationApply + const OperationBaseline + const OperationLock + const OperationRecover + const OperationRollback + const OperationUnlock + type Option func(*Runner) error + func WithObserver(observer Observer) Option + func WithUnlockTimeout(timeout time.Duration) Option + type Phase uint8 + const PhaseCompleted + const PhaseFailed + const PhaseStarted + type Plan struct + func PlanDown(available []Migration, records []Record, count uint64) (Plan, error) + func PlanUp(available []Migration, records []Record) (Plan, error) + func (plan Plan) Steps() []Step + type Record struct + func NewRecord(kind RecordKind, version Version, name string, checksum Checksum, ...) (Record, error) + func (record Record) AppliedAt() time.Time + func (record Record) Checksum() Checksum + func (record Record) Dirty() bool + func (record Record) Duration() time.Duration + func (record Record) Kind() RecordKind + func (record Record) Name() string + func (record Record) Version() Version + type RecordKind uint8 + const RecordKindBaseline + const RecordKindMigration + type Recovery struct + func NewRecovery(version Version, checksum Checksum, action RecoveryAction) (Recovery, error) + func (recovery Recovery) Action() RecoveryAction + func (recovery Recovery) Checksum() Checksum + func (recovery Recovery) Version() Version + type RecoveryAction uint8 + const RecoveryMarkApplied + const RecoveryMarkRolledBack + type RecoveryResult struct + func (result RecoveryResult) Action() RecoveryAction + func (result RecoveryResult) Record() Record + type Result struct + func (result Result) Records() []Record + type Runner struct + func NewRunner(source Source, backend Backend, options ...Option) (*Runner, error) + func (runner *Runner) Baseline(ctx context.Context, baseline Baseline) (record Record, err error) + func (runner *Runner) Down(ctx context.Context, count uint64) (result Result, err error) + func (runner *Runner) Plan(ctx context.Context) (plan Plan, err error) + func (runner *Runner) Recover(ctx context.Context, recovery Recovery) (result RecoveryResult, err error) + func (runner *Runner) Status(ctx context.Context) (status Status, err error) + func (runner *Runner) Up(ctx context.Context) (result Result, err error) + type Session interface + Apply func(context.Context, Migration) (Record, error) + Prepare func(context.Context) error + Records func(context.Context) ([]Record, error) + Release func(context.Context) error + Rollback func(context.Context, Migration) (Record, error) + type Source interface + Load func(context.Context) ([]Migration, error) + type State uint8 + const StateApplied + const StateBaseline + const StateDirty + const StatePending + type Status struct + func BuildStatus(available []Migration, records []Record) (Status, error) + func (status Status) Entries() []StatusEntry + type StatusEntry struct + func (entry StatusEntry) AppliedAt() time.Time + func (entry StatusEntry) Checksum() Checksum + func (entry StatusEntry) Duration() time.Duration + func (entry StatusEntry) Name() string + func (entry StatusEntry) State() State + func (entry StatusEntry) Version() Version + type Step struct + func (step Step) Action() Action + func (step Step) Migration() Migration + type TransactionMode uint8 + const TransactionModeDefault + const TransactionModeNone + type Version uint64 + func (version Version) String() string