migrated

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2020 License: MIT Imports: 6 Imported by: 1

README

migrated

GoDoc CircleCI

A drop-in database migration helper.

Usage & Example

See example first.

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMigration

func CreateMigration(migrationDir string, timestamp int64, name string) (base string, err error)

CreateMigration creates a migration.

func DownMigration

func DownMigration(m *migrate.Migrate) error

DownMigration rollbacks *one* migration.

func ForceMigration

func ForceMigration(m *migrate.Migrate, version int) error

ForceMigration forces database migration.

func LogUpMigrationPlan

func LogUpMigrationPlan(logger LoggerT, driver source.Driver, fromVersion uint, limit int)

func UpMigration

func UpMigration(m *migrate.Migrate, limit int) error

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.

Directories

Path Synopsis
Commandline entrypoint for migration task.
Commandline entrypoint for migration task.
example module
gobindata creates migrate source from go-bindata
gobindata creates migrate source from go-bindata

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL