Documentation ¶
Overview ¶
Package migration provides a "micro-framework" for migration management: each migration is a simple function that returns an error. All migration functions are executed in the order they were registered.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCannotForceMandatory = errors.New("mandatory migrations can only run once")
ErrCannotForceMandatory is the error returned by Run when the force parameter is supplied without the name of a migration to run.
var ErrDuplicateMigration = errors.New("there's already a migration with this name")
ErrDuplicateMigration is the error returned by Register when the given name is already in use.
var ErrMigrationAlreadyExecuted = errors.New("migration already executed")
ErrMigrationAlreadyExecuted is the error returned by Run when the given name was previously executed and the force parameter was not supplied.
var ErrMigrationMandatory = errors.New("migration is mandatory")
ErrMigrationMandatory is the error returned by Run when the given name is not an optional migration. It should be executed calling Run.
var ErrMigrationNotFound = errors.New("migration not found")
ErrMigrationNotFound is the error returned by RunOptional when the given name is not a registered migration.
Functions ¶
func Register ¶
func Register(name string, fn MigrateFunc) error
Register register a new migration for later execution with the Run functions.
func RegisterOptional ¶
func RegisterOptional(name string, fn MigrateFunc) error
RegisterOptional register a new migration that will not run automatically when calling the Run funcition.
Types ¶
type MigrateFunc ¶
type MigrateFunc func() error
MigrateFunc represents a migration function, that can be registered with the Register function. Migrations are later ran in the registration order, and this package keeps track of which migrate have ran already.