target

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMigrationsTableName = "_migrations"

Variables

View Source
var (
	ErrDBInstanceNotFound = errors.New("db instance not found on the context")
	ErrInvalidDBInstance  = errors.New("context has an invalid db instance")
)
View Source
var (
	ErrMissingSource = errors.New("source is required")
)

Functions

func ContextWithDB

func ContextWithDB(ctx context.Context, db DB) context.Context

ContextWithDB returns a context with the given db attached.

Types

type DB

type DB interface {
	DBExecer
	Begin() (*sql.Tx, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
}

type DBExecer

type DBExecer interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
}

func DBFromContext

func DBFromContext(ctx context.Context) (DBExecer, error)

type Driver

type Driver interface {
	migrations.TargetLocker
	Add(migration migrations.Migration) error
	Remove(migration migrations.Migration) error
}

type Option

type Option func(target *Target) error

func Table

func Table(tableName string) Option

type Target

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

func NewTarget

func NewTarget(source migrations.Source, db DB, driver Driver, options ...Option) (*Target, error)

func (*Target) Add

func (target *Target) Add(migration migrations.Migration) error

func (*Target) Create

func (target *Target) Create() error

func (*Target) Current

func (target *Target) Current() (migrations.Migration, error)

func (*Target) Destroy

func (target *Target) Destroy() error

func (*Target) Done

func (target *Target) Done() ([]migrations.Migration, error)

func (*Target) Remove

func (target *Target) Remove(migration migrations.Migration) error

Jump to

Keyboard shortcuts

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