Versions in this module Expand all Collapse all v1 v1.1.0 Nov 19, 2026 v1.0.1 Nov 17, 2026 Changes in this version + const DefaultLockWait + const DefaultTable + const RunCallbacksRepairKey + var ErrApprovalTarget = dialect.ErrApprovalTarget + var ErrBadFileName = source.ErrBadFileName + var ErrBadPrecondition = script.ErrBadPrecondition + var ErrBaselineNotEmpty = errors.New("baseline requires an empty history table") + var ErrBelowBaseline = errors.New("target version is below the baseline") + var ErrCallbackRecoveryRequired error = callbackRecoveryError + var ErrChecksumMismatch = errors.New("applied migration was modified") + var ErrCommitOutcomeUnknown = errors.New(...) + var ErrContentBeforeMarker = script.ErrContentBeforeMarker + var ErrDirty = errors.New("database is dirty: a migration failed part-way; " + dirtyGuidance) + var ErrDuplicateMarker = script.ErrDuplicateMarker + var ErrDuplicateVersion = source.ErrDuplicateVersion + var ErrEmptyUp = source.ErrEmptyUp + var ErrHistoryRowNotFound = history.ErrNotFound + var ErrInvalidArgument = errors.New("invalid argument") + var ErrInvalidIdentifier = dialect.ErrInvalidIdentifier + var ErrInvalidVersion = errors.New("invalid version") + var ErrIrreversible = errors.New("migration has no down section") + var ErrLockLost = dialect.ErrLockLost + var ErrLockTimeout = dialect.ErrLockTimeout + var ErrMisplacedDirective = source.ErrMisplacedDirective + var ErrMissingMigration = errors.New("applied migration is missing from the source") + var ErrMissingUp = source.ErrMissingUp + var ErrNotEnoughApplied = errors.New("not enough applied migrations") + var ErrOutOfOrder = errors.New("pending migration is older than the latest applied version") + var ErrPLSQLBlock = script.ErrPLSQLBlock + var ErrPlanChanged = errors.New("plan or target changed since it was approved") + var ErrPreconditionFailed = errors.New("precondition failed") + var ErrSQLPLBlock = script.ErrSQLPLBlock + var ErrTSQLBatch = script.ErrTSQLBatch + var ErrTagNotFound = errors.New("tag not found") + var ErrTransactionControl = errors.New(...) + var ErrUnbalancedBlock = script.ErrUnbalancedBlock + var ErrUnknownDirective = script.ErrUnknownDirective + var ErrUnresolvedPlaceholder = errors.New("unresolved placeholder") + var ErrUnsupportedDialect = dialect.ErrUnsupported + var ErrUpInDownFile = source.ErrUpInDownFile + var ErrVersionNotFound = errors.New("version not found") + func ErrorCodes(err error) []string + func LintRules() []string + type Applied struct + Duration time.Duration + MarkedRan bool + type Callback struct + Event string + Source string + Statements []string + type Direction int + const Down + const Up + func (d Direction) String() string + type DownTarget struct + Steps int + Tag string + To string + type Event struct + Direction Direction + Duration time.Duration + Err error + Migration Migration + type Executor 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 Finding struct + Event string + Hint string + Message string + Rule string + SQL string + Severity string + Source string + Statement int + Version string + func Lint(dialectName string, opts ...Option) ([]Finding, error) + type GoMigration struct + Description string + Down func(ctx context.Context, ex Executor) error + NoTx bool + Up func(ctx context.Context, ex Executor) error + Version string + type Hooks struct + After func(ctx context.Context, e Event) + Before func(ctx context.Context, e Event) error + type Info struct + ExecutionTime time.Duration + InstalledBy string + InstalledOn time.Time + State State + Tag string + type Migration struct + Checksum string + Conditional bool + Description string + NoTx bool + Repeatable bool + Reversible bool + Source string + Version string + func (m Migration) Label() string + type MigrationError struct + Direction Direction + Dirty bool + Err error + SQL string + Statement int + Version string + func (e *MigrationError) Error() string + func (e *MigrationError) Unwrap() []error + type Migrator struct + func New(db *sql.DB, dialectName string, opts ...Option) (*Migrator, error) + func (m *Migrator) Baseline(ctx context.Context, version, description string) error + func (m *Migrator) Callbacks(dir Direction) []Callback + func (m *Migrator) Down(ctx context.Context, t DownTarget, opts ...RunOption) (*Result, error) + func (m *Migrator) Lint() []Finding + func (m *Migrator) MarkApplied(ctx context.Context, version string) error + func (m *Migrator) Migrations() []Migration + func (m *Migrator) Plan(ctx context.Context, target string) ([]Migration, error) + func (m *Migrator) PlanDown(ctx context.Context, t DownTarget) ([]Migration, error) + func (m *Migrator) PlanDownWithID(ctx context.Context, t DownTarget) ([]Migration, string, error) + func (m *Migrator) PlanID(dir Direction, plan []Migration) string + func (m *Migrator) PlanRepair(ctx context.Context, target RepairTarget) (*RepairPlan, error) + func (m *Migrator) PlanWithID(ctx context.Context, target string) ([]Migration, string, error) + func (m *Migrator) Redo(ctx context.Context) (*Result, error) + func (m *Migrator) Repair(ctx context.Context, targets ...RepairTarget) (*RepairResult, error) + func (m *Migrator) Statements(mig Migration, dir Direction) []string + func (m *Migrator) Status(ctx context.Context) (*Status, error) + func (m *Migrator) Tag(ctx context.Context, tag string) error + func (m *Migrator) Up(ctx context.Context, opts ...RunOption) (*Result, error) + func (m *Migrator) UpTo(ctx context.Context, version string, opts ...RunOption) (*Result, error) + func (m *Migrator) Validate(ctx context.Context) error + type Option func(*options) + func WithAllowMissing(allow bool) Option + func WithAllowOutOfOrder(allow bool) Option + func WithApprovalEndpoint(endpoint string) Option + func WithBaselineOnMigrate(version string) Option + func WithContexts(contexts ...string) Option + func WithFS(fsys fs.FS) Option + func WithGoMigrations(ms ...GoMigration) Option + func WithHooks(h Hooks) Option + func WithInstalledBy(name string) Option + func WithLabels(labels ...string) Option + func WithLockWait(d time.Duration) Option + func WithLogger(l halolog.Logger) Option + func WithPlaceholders(values map[string]string) Option + func WithTable(name string) Option + type RepairAction string + const RepairAcceptChecksum + const RepairClearFailed + type RepairPlan struct + NewChecksum string + NewKind string + State State + StoredChecksum string + StoredKind string + type RepairResult struct + Realigned []string + RemovedFailed int64 + type RepairTarget struct + Action RepairAction + Migration string + type Result struct + Applied []Applied + Direction Direction + type RunOption func(*runOptions) + func ExpectPlan(id string) RunOption + func ExpectTargetPlan(id string) RunOption + type State string + const StateApplied + const StateBaseline + const StateBelowBase + const StateFailed + const StateMarkedRan + const StateMissing + const StateModified + const StateOutOfOrder + const StateOutdated + const StatePending + const StateRunAlways + const StateSkipped + type Status struct + CallbackRecoveryRequired bool + Current string + Dirty bool + Migrations []Info + Pending int