Documentation ¶
Overview ¶
Package gomigration provides some basic functionality to run migrations.
Index ¶
- type Migrate
- type Migration
- type MigrationManager
- func (mM MigrationManager) CheckIfExecuted(session *dbr.Session, migration Migration) bool
- func (mM MigrationManager) CheckIfSane(migrations []Migration) error
- func (mM MigrationManager) Init()
- func (mM MigrationManager) MarkAsExecuted(transaction *dbr.Tx, migration Migration) (rErr error)
- func (mM MigrationManager) MarkAsNotExecuted(transaction *dbr.Tx, migration Migration) (rErr error)
- func (mM MigrationManager) MigrationRunner(migrations []Migration)
- func (mM MigrationManager) RunSingleMigrationDown(session *dbr.Session, migration Migration) error
- func (mM MigrationManager) RunSingleMigrationUp(session *dbr.Session, migration Migration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MigrationManager ¶
type MigrationManager struct { Connection *dbr.Connection // contains filtered or unexported fields }
func NewMigrationManager ¶
func NewMigrationManager(c *dbr.Connection) MigrationManager
NewMigrationManager returns a default MigrationManager and initializes it.
func NewMigrationManagerExplicitTableName ¶
func NewMigrationManagerExplicitTableName(c *dbr.Connection, tableName string) MigrationManager
NewMigrationManagerExplicitTableName returns a new MigrationManager with a named migration-meta-data table and initializes it.
func (MigrationManager) CheckIfExecuted ¶
func (mM MigrationManager) CheckIfExecuted(session *dbr.Session, migration Migration) bool
CheckIfExecuted checks if an migration ran before and returns true if yes and otherwise false.
func (MigrationManager) CheckIfSane ¶
func (mM MigrationManager) CheckIfSane(migrations []Migration) error
CheckIfSane checks if the list of migrations has any name twice and stops on first error or returns nil.
func (MigrationManager) Init ¶
func (mM MigrationManager) Init()
Init initializes the necessary DbTable for the migrations and panics if not successful.
func (MigrationManager) MarkAsExecuted ¶
func (mM MigrationManager) MarkAsExecuted(transaction *dbr.Tx, migration Migration) (rErr error)
MarkAsExecuted marks that a single Migration was applied.
func (MigrationManager) MarkAsNotExecuted ¶
func (mM MigrationManager) MarkAsNotExecuted(transaction *dbr.Tx, migration Migration) (rErr error)
MarkAsNotExecuted deletes the entry of an migration that was previously applied.
func (MigrationManager) MigrationRunner ¶
func (mM MigrationManager) MigrationRunner(migrations []Migration)
MigrationRunner applies all migrations that have not yet been executed.
func (MigrationManager) RunSingleMigrationDown ¶
func (mM MigrationManager) RunSingleMigrationDown(session *dbr.Session, migration Migration) error
RunSingleMigrationDown undos a migration if it was already applied, otherwise throws an error.
func (MigrationManager) RunSingleMigrationUp ¶
func (mM MigrationManager) RunSingleMigrationUp(session *dbr.Session, migration Migration) error
RunSingleMigrationUp applies a single migration if it was not yet executed.