Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultPartsCountForFileName = 3 DirectionTextUp = "up" DirectionTextDown = "down" MigrationFileNameHelpText = "%s invalid migration file name format, should be of format {version}_{title}.{up|down}.{extension}" MigrationDirectionUp MigrationDirection = iota MigrationDirectionDown FileNameDefaultExtensionDelimiter = "." FileNameVersionPlaceholder = "{version}" FileNameDirectionPlaceholder = "{direction}" FileNameExtensionPlaceholder = "{extension}" CommandUsageHelpText = "Description:\n Execute a migration to a specified version or the latest available version." + "\n\nUsage:\n ./main [options] [<version>] [<direction>] " + "\n\nArguments:\n version The version number (YYYYMMDDHHMMSS) to migrate to." + "\n direction The direction to apply a migration towards. Possible values - up, down" + "\n\nOptions:\n migrate Applies all the unapplied migrations in the ascending order." + "\n up Rolls up the migration by one version." + "\n down Rolls down the migration by one version." + "\n execute Applies the specified migration. No warning is given even if the migration is already applied. " + "Usage - ./main execute <version> <direction>" + "\n version Displays the current DB migration version." )
Variables ¶
This section is empty.
Functions ¶
func DefaultFileNameFormat ¶
func DefaultFileNameFormat() string
Types ¶
type Config ¶
type Config struct { AbsoluteMigrationsDirectory string Debug bool // Filename config // TODO - allow overriding of this value via interface implementation // TODO - Filename config made part of this config in order to allow customization in future FileNameVersionDelimiter string VersionIndexByDelimiter int PartsCountByDelimiter int FileNameFormat string }
type MigrationDirection ¶
type MigrationDirection int
func (MigrationDirection) IsValid ¶
func (m MigrationDirection) IsValid() bool
func (MigrationDirection) String ¶
func (m MigrationDirection) String() string
type MigrationInstruction ¶
type MigrationInstruction struct { Version int Direction MigrationDirection Command string }
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
func NewMigrator ¶
func NewMigratorWithConfig ¶
func NewMigratorWithConfig( config Config, driver db.DriverInterface, ) *Migrator
Click to show internal directories.
Click to hide internal directories.