migration

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TranslateState

func TranslateState(state State) []string

Types

type Config

type Config struct {
	Path            string
	AllowOutOfOrder bool
	Database        database.Database

	*Hooks
}

type Data

type Data struct {
	Sequence      *uint64
	Version       string
	ScriptName    string
	Description   string
	Checksum      string
	AppliedBy     string
	AppliedAt     uint64
	ExecutionTime uint32
	Status        State
}

type Hooks

type Hooks struct {
	PreMigrate  func(dt Data)
	PostMigrate func(dt Data)
	MigrateErr  func(dt Data, err error)

	PreRollback  func(dt Data)
	PostRollback func(dt Data)
	RollbackErr  func(dt Data, err error)
}

type Properties

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

func New

func New(config *Config) (*Properties, error)

func (*Properties) Create

func (p *Properties) Create(name string) ([]string, error)

func (*Properties) Get

func (p *Properties) Get() ([]*Data, error)

func (*Properties) Migrate

func (p *Properties) Migrate() error

func (*Properties) Rollback

func (p *Properties) Rollback(steps int) error

type State

type State uint16
const (
	UnknownState State = 0

	//PendingState means that migration has not been applied yet.
	PendingState State = 1 << (iota - 1)

	//SuccessState means that migration is succeeded.
	SuccessState

	//IgnoredState means that migration will not be considered when running migrate.
	IgnoredState

	//AvailableState means that backward migration is ready to be applied if desired.
	AvailableState

	//UndoneState means that migration is succeeded but has since been undone.
	UndoneState

	//MissingState means that migration has been succeeded/failed but could not be resolved.
	MissingState

	//FailedState means that migration is failed.
	FailedState

	//FutureState means that migration has been succeeded/failed and its version is higher
	//than the one listed on schema history table.
	FutureState

	//OutdatedState is a repeatable migration that is outdated and should be re-applied
	OutdatedState

	//SupersededState is a repeatable migration that is outdated and has already been
	//superseded by a newer one
	SupersededState
)

Jump to

Keyboard shortcuts

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