Documentation ¶
Index ¶
- func CreateMigration(migrationDir string, timestamp int64, name string) (base string, err error)
- func DownMigration(m *migrate.Migrate) error
- func ForceMigration(m *migrate.Migrate, version int) error
- func LogUpMigrationPlan(logger LoggerT, driver source.Driver, fromVersion uint, limit int)
- func UpMigration(m *migrate.Migrate, limit int) error
- type LoggerT
- type MigratorConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMigration ¶
CreateMigration creates a migration.
func DownMigration ¶
func DownMigration(m *migrate.Migrate) error
DownMigration rollbacks *one* migration.
func ForceMigration ¶
ForceMigration forces database migration.
func LogUpMigrationPlan ¶
func UpMigration ¶
UpMigration applies migrations. If limit is positive, up to limit migrations will be used.
Types ¶
type LoggerT ¶
type LoggerT interface { Infof(format string, a ...interface{}) Warnf(format string, a ...interface{}) Errorf(format string, a ...interface{}) }
LoggerT defines a common logger interface used by migrator.
type MigratorConfig ¶
type MigratorConfig struct { Logger LoggerT // base dir of the migration directories MigrationBaseDir string // migration database driver constructor CreateDatabase func() (string, database.Driver, error) // migration source constructor CreateSource func() (string, source.Driver, error) }
Migrator configuration object.
func (*MigratorConfig) MustCreateDatabase ¶
func (c *MigratorConfig) MustCreateDatabase() (string, database.Driver)
MustCreateSource creates a database driver from config. It panics on error.
func (*MigratorConfig) MustCreateSource ¶
func (c *MigratorConfig) MustCreateSource() (string, source.Driver)
MustCreateSource creates a database source from config. It panics on error.
func (*MigratorConfig) MustGetMigrationBaseDir ¶
func (c *MigratorConfig) MustGetMigrationBaseDir() string
MustGetMigrationBaseDir returns migration files base dir. It panics on error.
func (*MigratorConfig) MustNewMigrator ¶
func (c *MigratorConfig) MustNewMigrator() *migrate.Migrate
MustNewMigrator creates a migrator instance from dsn string. It panics on error.
Click to show internal directories.
Click to hide internal directories.