migration

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DateLayout = "20060102150405"

DateLayout is the date layout used to timestamp migrations.

View Source
const NamePattern = `[a-zA-Z0-9]([a-zA-Z0-9_-]*[a-zA-Z0-9])?`

NamePattern is the accepted regex pattern for a migration name (excluding timestamp prefix).

Variables

View Source
var (
	ErrWrongOrder       = errors.New("migrate up section must appear before migrate down section")
	ErrMissingUpSection = errors.New("missing up section in migration file")
)

Functions

This section is empty.

Types

type Migration

type Migration struct {
	Name    string
	Date    time.Time
	UpCmd   *exec.Cmd
	DownCmd *exec.Cmd
	// contains filtered or unexported fields
}

Migration represents a single migration's file and state.

func New

func New(filePath string) (*Migration, error)

New makes a lazy initialisation of a Migration struct. Neither does it check if the file exists nor does it parse or validate its contents.

func (*Migration) Down

func (m *Migration) Down() error

func (*Migration) Parse

func (m *Migration) Parse(executor string) error

Parse gets the migration file's content and extracts the Up and Down commands from it with respect to the given executor (path to binary).

func (*Migration) Up

func (m *Migration) Up() error

Jump to

Keyboard shortcuts

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