migrator

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migration

type Migration struct {
	Name string
	Func func(*sql.Tx) error
}

Migration represents a single migration

func (*Migration) String

func (m *Migration) String() string

String returns a string representation of the migration

type MigrationNoTx

type MigrationNoTx struct {
	Name string
	Func func(*sql.DB) error
}

MigrationNoTx represents a single not transactional migration

func (*MigrationNoTx) String

func (m *MigrationNoTx) String() string

type Migrator

type Migrator struct {
	TableName string
	// contains filtered or unexported fields
}

Migrator is the migrator implementation

func New

func New(opts ...Option) (*Migrator, error)

New creates a new migrator instance

func (*Migrator) Migrate

func (m *Migrator) Migrate(db *sql.DB) error

Migrate applies all available migrations

func (*Migrator) NeedUpgrade

func (m *Migrator) NeedUpgrade(db *sql.DB) (bool, error)

NeedUpgrade returns True if database need to be updated with migrations

func (*Migrator) Pending

func (m *Migrator) Pending(db *sql.DB) ([]interface{}, error)

Pending returns all pending (not yet applied) migrations

type Option

type Option func(*Migrator)

Option sets options such migrations or table name.

func Migrations

func Migrations(migrations ...interface{}) Option

Migrations creates an option with provided migrations

func SetNotice

func SetNotice(noticeFunc func(string)) Option

SetNotice overrides the default standard output function

func TableName

func TableName(tableName string) Option

TableName creates an option to allow overriding the default table name

Jump to

Keyboard shortcuts

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