migrate

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Error = errs.Class("migrate")

Error is the default migrate errs class

Functions

func Create

func Create(identifier string, db DB) error

Create with a previous schema check

Types

type Action

type Action interface {
	Run(log *zap.Logger, db DB, tx *sql.Tx) error
}

Action is something that needs to be done

type DB

type DB interface {
	Begin() (*sql.Tx, error)
	Schema() string
	Rebind(string) string
}

DB is the minimal implementation that is needed by migration.

type Func

type Func func(log *zap.Logger, db DB, tx *sql.Tx) error

Func is an arbitrary operation

func (Func) Run

func (fn Func) Run(log *zap.Logger, db DB, tx *sql.Tx) error

Run runs the migration

type Migration

type Migration struct {
	Table string
	Steps []*Step
}

Migration describes a migration steps

func (*Migration) Run

func (migration *Migration) Run(log *zap.Logger, db DB) error

Run runs the migration steps

func (*Migration) TargetVersion

func (migration *Migration) TargetVersion(version int) *Migration

TargetVersion returns migration with steps upto specified version

func (*Migration) ValidTableName

func (migration *Migration) ValidTableName() error

ValidTableName checks whether the specified table name is valid

func (*Migration) ValidateSteps

func (migration *Migration) ValidateSteps() error

ValidateSteps checks whether the specified table name is valid

type SQL

type SQL []string

SQL statements that are executed on the database

func (SQL) Run

func (sql SQL) Run(log *zap.Logger, db DB, tx *sql.Tx) (err error)

Run runs the SQL statements

type Step

type Step struct {
	Description string
	Version     int // Versions should start at 0
	Action      Action
}

Step describes a single step in migration.

Jump to

Keyboard shortcuts

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