Documentation ¶
Index ¶
- Variables
- func SwapPlanDirection(plan *models.Plan)
- type Config
- type EngineOption
- type Interceptor
- type Logger
- type Morph
- func (m *Morph) AddInterceptor(version int, direction models.Direction, handler Interceptor)
- func (m *Morph) Apply(limit int) (int, error)
- func (m *Morph) ApplyAll() error
- func (m *Morph) ApplyDown(limit int) (int, error)
- func (m *Morph) ApplyPlan(plan *models.Plan) error
- func (m *Morph) Close() error
- func (m *Morph) Diff(mode models.Direction) ([]*models.Migration, error)
- func (m *Morph) GeneratePlan(migrations []*models.Migration, auto bool) (*models.Plan, error)
- func (m *Morph) GetOppositeMigrations(migrations []*models.Migration) ([]*models.Migration, error)
- func (m *Morph) RemoveInterceptor(version int, direction models.Direction)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func SwapPlanDirection ¶ added in v1.1.0
SwapPlanDirection alters the plan direction to the opposite direction.
Types ¶
type EngineOption ¶
func SetDryRun ¶ added in v1.1.0
func SetDryRun(enable bool) EngineOption
SetDryRun will not execute any migrations if set to true, but will still log the migrations that would be executed.
func SetMigrationTableName ¶
func SetMigrationTableName(name string) EngineOption
func SetStatementTimeoutInSeconds ¶
func SetStatementTimeoutInSeconds(n int) EngineOption
func WithLock ¶
func WithLock(key string) EngineOption
WithLock creates a lock table in the database so that the migrations are guaranteed to be executed from a single instance. The key is used for naming the mutex.
func WithLogger ¶
func WithLogger(logger Logger) EngineOption
type Interceptor ¶ added in v1.1.0
type Interceptor func() error
Interceptor is a handler function that being called just before the migration applied. If the interceptor returns an error, migration will be aborted.
type Logger ¶
type Logger interface { Printf(format string, v ...interface{}) Println(v ...interface{}) }
type Morph ¶
type Morph struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, driver drivers.Driver, source sources.Source, options ...EngineOption) (*Morph, error)
New creates a new instance of the migrations engine from an existing db instance and a migrations source. If the driver implements the Lockable interface, it will also wait until it has acquired a lock. The context is propagated to the drivers lock method (if the driver implements divers.Locker interface) and it can be used to cancel the lock acquisition.
func (*Morph) AddInterceptor ¶ added in v1.1.0
func (m *Morph) AddInterceptor(version int, direction models.Direction, handler Interceptor)
AddInterceptor registers a handler function to be executed before the actual migration
func (*Morph) ApplyDown ¶
ApplyDown rollbacks a limited number of migrations if limit is given below zero, all down scripts are going to be applied.
func (*Morph) Diff ¶ added in v1.1.0
Diff returns the difference between the applied migrations and the available migrations.
func (*Morph) GeneratePlan ¶ added in v1.1.0
GeneratePlan returns the plan to apply these migrations and also includes the safe rollback steps for the given migrations.