sqlmigrate

package module
v0.0.0-...-79cf3b7 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(db *sql.DB, m MigrationSource, dir MigrationDirection) (int, error)

Exec executes a set of migrations Returns the number of applied migrations.

func SetMigrationsTableName

func SetMigrationsTableName(name string)

SetMigrationsTableName sets the table name for the applied migrations

Types

type AppliedMigration

type AppliedMigration struct {
	ID        string
	AppliedAt time.Time
}

AppliedMigration is an applied migration stored in a table

type ApplyMigrationError

type ApplyMigrationError struct {
	ID    string
	Query string
	Err   error
}

ApplyMigrationError is an error while applying a migration

func (ApplyMigrationError) Error

func (a ApplyMigrationError) Error() string

Error returns a string representation of the ApplyMigrationError

type MemoryMigrationSource

type MemoryMigrationSource struct {
	Migrations []*Migration
}

MemoryMigrationSource returns the migrations passed as parameter in the constructor

func (MemoryMigrationSource) FindMigrations

func (m MemoryMigrationSource) FindMigrations() ([]*Migration, error)

FindMigrations returns the migrations to be applied

type Migration

type Migration struct {
	ID   string
	Up   []string
	Down []string
}

Migration is a sql migration

type MigrationDirection

type MigrationDirection uint8

MigrationDirection is a migration direction

const (
	Up MigrationDirection = iota + 1
	Down
)

these are the possible migration direction

type MigrationSource

type MigrationSource interface {
	// Finds the migrations.
	// The resulting slice of migrations should be sorted by Id.
	FindMigrations() ([]*Migration, error)
}

MigrationSource is the interface for retrieving the migrations to be applied

Jump to

Keyboard shortcuts

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