migrate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Down

func Down(c *SQLConnection) (record string, err error)

Down reverts a single database migration. It returns the reverted migration name.

func Status

func Status(c *SQLConnection) (err error)

Status prints the database schema status.

func Sync

func Sync(c *SQLConnection) (done []string, err error)

Sync migrates the database to latest schema.

func Up

func Up(c *SQLConnection) (record string, err error)

Up executes a single database migration. It returns the last migration name.

Types

type ByID

type ByID []*migrate.Migration

ByID sorts migrations by ID.

func (ByID) Len

func (b ByID) Len() int

func (ByID) Less

func (b ByID) Less(i, j int) bool

func (ByID) Swap

func (b ByID) Swap(i, j int)

type LocalMigrationSource

type LocalMigrationSource struct {
	Dir string
}

LocalMigrationSource migrates from a local files.

func (LocalMigrationSource) FindMigrations

func (l LocalMigrationSource) FindMigrations() (m []*migrate.Migration, err error)

FindMigrations implements migrate.MigrationSource{} interface.

type SQLConfig

type SQLConfig struct {
	Dialect string

	Address  string // Format like "host:port"
	Database string

	User     string
	Password string
}

SQLConfig is config for SQL connection.

type SQLConnection

type SQLConnection struct {
	// contains filtered or unexported fields
}

SQLConnection represents a database connection used for migration.

func NewMySQLConnection

func NewMySQLConnection(config *SQLConfig, migrationsDir string) (connection *SQLConnection, err error)

NewMySQLConnection creates a new database connection for MySQL.

func (*SQLConnection) CloseMySQLConnection

func (c *SQLConnection) CloseMySQLConnection() error

CloseMySQLConnection closes the database connection.

Jump to

Keyboard shortcuts

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