migrate

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, db beginner, m []Migration) error

Run runs all unapplied migrations in m.

func Validity

func Validity(migrations []Migration) error

Validity returns an error if the provided list of migrations isn't valid. The required properties are:

names are well formed
names are in order
keys (YYYY-MM-DD.N) are not duplicated

Types

type Error

type Error struct {
	Mig   Migration
	Index int
	Err   error
}

Error records an error and the migration that caused it. Index is the index of Mig in the given list of migrations, or the index where it would have been if it's not in the list.

func (*Error) Error

func (e *Error) Error() string

type Migration

type Migration struct {
	Name        string
	SQL         string // unavailable for applied migrations
	Hash        string // internally computed if unset
	RequiredSHA string
	OutsideTx   bool
}

Migration describes a PostgreSQL database migration. At least one of SQL and Hash must be set. If both are set, Hash must be the SHA-256 of SQL.

func FilterApplied

func FilterApplied(db execer, ms []Migration) ([]Migration, error)

FilterApplied returns the slice of ms containing all migrations in ms that haven't yet been applied.

func GetApplied

func GetApplied(ctx context.Context, db execer) ([]Migration, error)

GetApplied returns the list of currently-applied migrations.

func (Migration) String

func (m Migration) String() string

Jump to

Keyboard shortcuts

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