Documentation ¶
Index ¶
- Variables
- func SwapPlanDirection(plan *models.Plan)
- type Config
- type EngineOption
- type Logger
- type Morph
- 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)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func SwapPlanDirection ¶
SwapPlanDirection alters the plan direction to the opposite direction.
Types ¶
type EngineOption ¶
func SetDryRun ¶
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 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) 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 ¶
Diff returns the difference between the applied migrations and the available migrations.
func (*Morph) GeneratePlan ¶
GeneratePlan returns the plan to apply these migrations and also includes the safe rollback steps for the given migrations.