Documentation ¶
Index ¶
- Constants
- Variables
- type Migrator
- func (m Migrator) Create(desc string) error
- func (m Migrator) CurrentVersion() (string, error)
- func (m Migrator) Down(toVersion string) error
- func (m *Migrator) FindMigrationGaps(mvs []models.MigrationVersion, currentVersion string) (migrationGaps map[string]models.MigrationVersion, lastValidVersion string)
- func (m Migrator) Force(toVersion string) error
- func (m *Migrator) GetConfirmation(promptMsg string, trueValues []string) error
- func (m Migrator) GetMigrationVersionInfo() ([]models.MigrationVersion, error)
- func (m Migrator) GetMigrationVersionInfoMap() (map[string]*models.MigrationVersion, error)
- func (m Migrator) GetMigrationsToRun(mvs []models.MigrationVersion, ...) ([]models.MigrationVersion, error)
- func (m Migrator) Goto(toVersion string) error
- func (m *Migrator) Migrate(command, toVersion string) error
- func (m Migrator) Up(toVersion string) error
Constants ¶
const ( COMMAND_CREATE = "create" COMMAND_UP = "up" COMMAND_DOWN = "down" COMMAND_GOTO = "goto" COMMAND_LIST = "list" COMMAND_VERSION = "version" COMMAND_FIX = "fix" COMMAND_FORCE = "force" DIRECTION_UP = "up" DIRECTION_DOWN = "down" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Migrator ¶
type Migrator struct { DBRepository *dbrepo.DBRepo App *config.AppConfig // contains filtered or unexported fields }
func NewMigrator ¶
NewMigrator creates a *Migrator that can migrate a DB to different migration versions
func (Migrator) Create ¶
Create creates an up and down migration file in the configured migration directory
func (Migrator) CurrentVersion ¶
CurrentVersion returns the current db migration version
func (*Migrator) FindMigrationGaps ¶
func (m *Migrator) FindMigrationGaps(mvs []models.MigrationVersion, currentVersion string) (migrationGaps map[string]models.MigrationVersion, lastValidVersion string)
FindMigrationGaps finds all migrations that are older than the current migration version and have not yet been run and returns them as a slice of models.MigrationVersion. The last migration version (lastValidVersion) that was migrated before the oldest migration gap version is also returned as this is usefull for the fix command
func (*Migrator) GetConfirmation ¶
GetConfirmation prompts users to confirm whether they want to continue with a command
func (Migrator) GetMigrationVersionInfo ¶
func (m Migrator) GetMigrationVersionInfo() ([]models.MigrationVersion, error)
GetMigrationVersionInfo gathers details of all migrated versions and migrations files
func (Migrator) GetMigrationVersionInfoMap ¶
func (m Migrator) GetMigrationVersionInfoMap() (map[string]*models.MigrationVersion, error)
GetMigrationVersionInfoMap reads all files in the migration directory and parses the filenames to determine all the migration vesions and descriptions. There details are return in a map of models.MigrationVersion items
func (Migrator) GetMigrationsToRun ¶
func (m Migrator) GetMigrationsToRun(mvs []models.MigrationVersion, currentVersion, toVersion, migrationDirection, command string) ([]models.MigrationVersion, error)
GetMigrationsToRun determines which migrations must be run and returns the result as a slice of models.MigrationVersion