models

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentPlanVersion = 1

Variables

View Source
var ErrInvalidPlanVersion = errors.New("invalid plan version")
View Source
var (
	ErrParse = fmt.Errorf("no match")
)
View Source
var Regex = regexp.MustCompile(`^([0-9]+)_(.*)\.(` + string(Down) + `|` + string(Up) + `)\.(.*)$`)

Regex matches the following pattern:

123_name.up.ext
123_name.down.ext

Functions

This section is empty.

Types

type Direction

type Direction string

Direction is either up or down.

const (
	Down Direction = "down"
	Up   Direction = "up"
)

type Migration

type Migration struct {
	Bytes     []byte
	Name      string
	RawName   string
	Version   uint32
	Direction Direction
}

func NewMigration

func NewMigration(migrationBytes io.ReadCloser, fileName string) (*Migration, error)

func (*Migration) Query

func (m *Migration) Query() string

type Plan

type Plan struct {
	// Version is the version of the plan.
	Version int
	// Auto is the mode of the plan. If true, the plan will rollback automatically in case of an error.
	Auto bool
	// Migrations is the list of migrations to be applied.
	Migrations []*Migration
	// RevertMigrations is the list of migrations to be applied in case of an error.
	RevertMigrations []*Migration
}

func NewPlan

func NewPlan(migrations, rollback []*Migration, auto bool) *Plan

func (*Plan) Validate

func (p *Plan) Validate() error

Jump to

Keyboard shortcuts

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