Documentation ¶
Index ¶
- Constants
- type Collection
- type Migration
- type MigrationContainer
- func (thisMigration MigrationContainer) GetAbsolutePath() string
- func (thisMigration MigrationContainer) GetError() error
- func (thisMigration MigrationContainer) GetName() string
- func (thisMigration MigrationContainer) GetOrder() uint64
- func (thisMigration MigrationContainer) GetQuery() string
- func (thisMigration MigrationContainer) GetStatus() int8
- func (thisMigration MigrationContainer) HasFailed() bool
- func (thisMigration MigrationContainer) NewAsFailed(err error) Migration
- func (thisMigration MigrationContainer) NewAsNotRun() Migration
- func (thisMigration MigrationContainer) NewAsSuccessful() Migration
- func (thisMigration MigrationContainer) ShouldBeRun() bool
- func (thisMigration MigrationContainer) ShouldBeRunFirst(anotherMigration Migration) bool
- func (thisMigration MigrationContainer) WasSuccessful() bool
Constants ¶
const ( // StatusUnknown represents a MigrationContainer without a set status (default value). StatusUnknown int8 = 0 // StatusNotRun represents a MigrationContainer that hasn't been run yet. StatusNotRun int8 = 1 // StatusSuccessful represents a MigrationContainer that has been run and it was successful. StatusSuccessful int8 = 2 // StatusFailed represents a MigrationContainer that has been run and it failed. StatusFailed int8 = -1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection is a set of implementations of Migration indexed by migration absolute path.
func (*Collection) Add ¶
func (collection *Collection) Add(migration Migration) error
Add adds a new MigrationContainer to the collection.
func (*Collection) ContainsMigrationPath ¶
func (collection *Collection) ContainsMigrationPath(migrationPath string) bool
ContainsMigrationPath check if a given path is already in the collection.
func (*Collection) GetAll ¶
func (collection *Collection) GetAll() []Migration
GetAll returns all the migrations in the collection.
func (*Collection) GetMigrationsToRun ¶
func (collection *Collection) GetMigrationsToRun() []Migration
GetMigrationsToRun returns a list of migrations that has not been run yet.
func (*Collection) IsEmpty ¶
func (collection *Collection) IsEmpty() bool
IsEmpty returns true if the collection is empty.
type Migration ¶
type Migration interface { GetAbsolutePath() string GetName() string GetStatus() int8 GetOrder() uint64 ShouldBeRun() bool GetQuery() string NewAsFailed(err error) Migration NewAsSuccessful() Migration NewAsNotRun() Migration WasSuccessful() bool HasFailed() bool ShouldBeRunFirst(anotherMigration Migration) bool GetError() error }
Migration represents a database MigrationContainer and its state (immutable).
type MigrationContainer ¶ added in v1.4.1
type MigrationContainer struct {
// contains filtered or unexported fields
}
func (MigrationContainer) GetAbsolutePath ¶ added in v1.4.1
func (thisMigration MigrationContainer) GetAbsolutePath() string
GetAbsolutePath returns the absolute path of the MigrationContainer file.
func (MigrationContainer) GetError ¶ added in v1.4.1
func (thisMigration MigrationContainer) GetError() error
GetError returns the error that caused the MigrationContainer to fail.
func (MigrationContainer) GetName ¶ added in v1.4.1
func (thisMigration MigrationContainer) GetName() string
GetName returns the file name of the MigrationContainer file.
func (MigrationContainer) GetOrder ¶ added in v1.4.1
func (thisMigration MigrationContainer) GetOrder() uint64
GetOrder returns the order on which the MigrationContainer should be run.
func (MigrationContainer) GetQuery ¶ added in v1.4.1
func (thisMigration MigrationContainer) GetQuery() string
GetQuery returns the sql query of the MigrationContainer.
func (MigrationContainer) GetStatus ¶ added in v1.4.1
func (thisMigration MigrationContainer) GetStatus() int8
GetStatus returns the current status of the MigrationContainer using the constants on this package.
func (MigrationContainer) HasFailed ¶ added in v1.4.1
func (thisMigration MigrationContainer) HasFailed() bool
HasFailed returns true if the current status is StatusFailed.
func (MigrationContainer) NewAsFailed ¶ added in v1.4.1
func (thisMigration MigrationContainer) NewAsFailed(err error) Migration
NewAsFailed returns a copy of the MigrationContainer but with a StatusFailed status.
func (MigrationContainer) NewAsNotRun ¶ added in v1.4.1
func (thisMigration MigrationContainer) NewAsNotRun() Migration
NewAsNotRun returns a copy of the MigrationContainer but with a StatusNotRun status.
func (MigrationContainer) NewAsSuccessful ¶ added in v1.4.1
func (thisMigration MigrationContainer) NewAsSuccessful() Migration
NewAsSuccessful returns a copy of the MigrationContainer but with a StatusSuccessful status.
func (MigrationContainer) ShouldBeRun ¶ added in v1.4.1
func (thisMigration MigrationContainer) ShouldBeRun() bool
ShouldBeRun returns true if the MigrationContainer has not been run yet.
func (MigrationContainer) ShouldBeRunFirst ¶ added in v1.4.1
func (thisMigration MigrationContainer) ShouldBeRunFirst(anotherMigration Migration) bool
ShouldBeRunFirst returns true if this MigrationContainer needs to be run before the given MigrationContainer (used for sorting migrations).
func (MigrationContainer) WasSuccessful ¶ added in v1.4.1
func (thisMigration MigrationContainer) WasSuccessful() bool
WasSuccessful returns true if the current status is StatusSuccessful.