Versions in this module Expand all Collapse all v2 v2.1.1 Jan 21, 2025 v2.1.0 Jan 21, 2025 Changes in this version type Source + func NewMemorySource() Source v2.0.0 Jan 21, 2025 Changes in this version + var DefaultMigrationIDFormat = "20060102150405" + var ErrCurrentMigrationMoreRecent = errors.New("current migration is more recent than target migration") + var ErrCurrentMigrationNotFound = errors.New("current migration not found in the list") + var ErrDirtyMigration = errors.New("migration was started but not completed and now it is in a dirty state") + var ErrInvalidAction = errors.New("undefined action") + var ErrMigrationAlreadyExists = errors.New("migration already exists") + var ErrMigrationNotFound = errors.New("migration not found") + var ErrMigrationNotListed = errors.New("migration not in the source list") + var ErrMigrationNotUndoable = errors.New("migration cannot be undone") + var ErrNoCurrentMigration = errors.New("no current migration") + var ErrNoMigrationsAvailable = errors.New("no migrations available") + var ErrStaleMigrationDetected = errors.New("stale migration detected") + var ErrStepOutOfIndex = errors.New("step out of bounds") + func NewQueryError(err error, query string) error + func WrapMigration(err error, migration Migration) *migrationError + func WrapMigrationID(err error, migrationID string) *migrationIDError + type Action struct + Action ActionType + Migration Migration + type ActionPLanner func(source Source, target Target) Planner + func StepPlanner(step int) ActionPLanner + type ActionType string + const ActionTypeDo + const ActionTypeUndo + type AfterExecuteInfo struct + Err error + Plan Plan + Stats *ExecutionResponse + type AfterExecuteMigrationInfo struct + ActionType ActionType + Err error + Migration Migration + type BaseMigration struct + func NewMigration(id, description string, do, undo migrationFunc) *BaseMigration + func (migration *BaseMigration) CanUndo() bool + func (migration *BaseMigration) Description() string + func (migration *BaseMigration) Do(ctx context.Context) error + func (migration *BaseMigration) ID() string + func (migration *BaseMigration) Next() Migration + func (migration *BaseMigration) Previous() Migration + func (migration *BaseMigration) SetNext(value Migration) Migration + func (migration *BaseMigration) SetPrevious(value Migration) Migration + func (migration *BaseMigration) String() string + func (migration *BaseMigration) Undo(ctx context.Context) error + type BeforeExecuteInfo struct + Plan Plan + type BeforeExecuteMigrationInfo struct + ActionType ActionType + Migration Migration + type ExecuteRequest struct + Plan Plan + type ExecutionResponse struct + Errored []*Action + Successful []*Action + func Migrate(ctx context.Context, source Source, target Target, opts ...MigrateOption) (ExecutionResponse, error) + type MigrateOption func(*migrateOptions) + func WithPlanner(planner ActionPLanner) MigrateOption + func WithRunner(runner *Runner) MigrateOption + func WithRunnerOptions(opts ...RunnerOption) MigrateOption + type Migration interface + CanUndo func() bool + Description func() string + Do func(ctx context.Context) error + ID func() string + Next func() Migration + Previous func() Migration + SetNext func(Migration) Migration + SetPrevious func(Migration) Migration + String func() string + Undo func(ctx context.Context) error + type MigrationError interface + Migration func() Migration + Unwrap func() error + type MigrationIDError interface + MigrationID func() string + type MigrationsError interface + Migrations func() []Migration + func WrapMigrations(err error, migrations ...Migration) MigrationsError + type Plan []*Action + type Planner interface + Plan func(ctx context.Context) (Plan, error) + func DoPlanner(source Source, target Target) Planner + func MigratePlanner(source Source, target Target) Planner + func ResetPlanner(source Source, target Target) Planner + func RewindPlanner(source Source, target Target) Planner + func UndoPlanner(source Source, target Target) Planner + type ProgressReporter interface + SetProgress func(progress int) + SetStep func(current int) + SetSteps func(steps []string) + SetTotal func(total int) + type QueryError interface + Query func() string + type Repository struct + func (r *Repository) Add(migration Migration) error + func (r *Repository) ByID(id string) (Migration, error) + func (r *Repository) List(_ context.Context) ([]Migration, error) + type Runner struct + func NewRunner(source Source, target Target, options ...RunnerOption) *Runner + func (runner *Runner) Execute(ctx context.Context, req *ExecuteRequest) (ExecutionResponse, error) + type RunnerOption func(*runnerOptions) + func WithReporter(reporter RunnerReporter) RunnerOption + type RunnerReporter interface + AfterExecute func(ctx context.Context, info *AfterExecuteInfo) + AfterExecuteMigration func(ctx context.Context, info *AfterExecuteMigrationInfo) + BeforeExecute func(ctx context.Context, info *BeforeExecuteInfo) + BeforeExecuteMigration func(ctx context.Context, info *BeforeExecuteMigrationInfo) + type Source interface + Add func(ctx context.Context, migration Migration) error + Load func(ctx context.Context) (Repository, error) + type Target interface + Add func(ctx context.Context, id string) error + Create func(ctx context.Context) error + Current func(ctx context.Context) (string, error) + Destroy func(ctx context.Context) error + Done func(ctx context.Context) ([]string, error) + FinishMigration func(ctx context.Context, id string) error + Lock func(ctx context.Context) (Unlocker, error) + Remove func(ctx context.Context, id string) error + StartMigration func(ctx context.Context, id string) error + type Unlocker interface + Unlock func(ctx context.Context) error Other modules containing this package github.com/jamillosantos/migrations