migratex

package
v0.3.750 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NilVersion = -1
)

Variables

View Source
var (
	// use same migration table name as mattes/migrate, so that we don't have to
	// migrate that.
	// TODO doesn't have to be a glob
	MigrationsTable = "schema_migrations"

	ErrLocked = errors.New("database is locked")
)

Functions

func Down

func Down(ctx context.Context, tx *sqlx.Tx, migs []Migration) error

func SetVersion

func SetVersion(ctx context.Context, tx *sqlx.Tx, version int64, dirty bool) error

func Up

func Up(ctx context.Context, tx *sqlx.Tx, migs []Migration) error

func Version

func Version(ctx context.Context, tx *sqlx.Tx) (version int64, dirty bool, err error)

Types

type ErrDirty

type ErrDirty string

ErrDirty is an error that is returned when a db is dirty.

func (ErrDirty) Error

func (e ErrDirty) Error() string

type ErrMigration

type ErrMigration string

ErrMigration represents an error running a specific migration in a specific direction

func (ErrMigration) Error

func (e ErrMigration) Error() string

type MigFields

type MigFields struct {
	UpFunc      func(context.Context, *sqlx.Tx) error
	DownFunc    func(context.Context, *sqlx.Tx) error
	VersionFunc func() int64
}

MigFields implements Migration and can be used for convenience.

func (MigFields) Down

func (m MigFields) Down(ctx context.Context, tx *sqlx.Tx) error

func (MigFields) Up

func (m MigFields) Up(ctx context.Context, tx *sqlx.Tx) error

func (MigFields) Version

func (m MigFields) Version() int64

type Migration

type Migration interface {
	Up(context.Context, *sqlx.Tx) error
	Down(context.Context, *sqlx.Tx) error
	Version() int64
}

type MultiError

type MultiError struct {
	Errs []error
}

MultiError holds multiple errors. If you have to handle one of these... I am so sorry.

func (MultiError) Error

func (m MultiError) Error() string

Jump to

Keyboard shortcuts

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