Documentation ¶
Index ¶
Constants ¶
const DefaultMigrationsTable = "_migrations"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MigrationsList ¶
type MigrationsList struct {
// contains filtered or unexported fields
}
MigrationsList defines a list with migration definitions
func (*MigrationsList) Item ¶
func (l *MigrationsList) Item(index int) *Migration
Item returns a single migration from the list by its index.
func (*MigrationsList) Items ¶
func (l *MigrationsList) Items() []*Migration
Items returns the internal migrations list slice.
func (*MigrationsList) Register ¶
func (l *MigrationsList) Register( up func(db dbx.Builder) error, down func(db dbx.Builder) error, optFilename ...string, )
Register adds new migration definition to the list.
If `optFilename` is not provided, it will try to get the name from its .go file.
The list will be sorted automatically based on the migrations file name.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner defines a simple struct for managing the execution of db migrations.
func NewRunner ¶
func NewRunner(db *dbx.DB, migrationsList MigrationsList) (*Runner, error)
NewRunner creates and initializes a new db migrations Runner instance.
func (*Runner) Down ¶
Down reverts the last `toRevertCount` applied migrations (in the order they were applied).
On success returns list with the reverted migrations file names.