migrate

package
v0.0.0-...-31ad618 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrDependencyMissing

type ErrDependencyMissing string

func (ErrDependencyMissing) Error

func (e ErrDependencyMissing) Error() string

type ErrDuplicateEntry

type ErrDuplicateEntry string

func (ErrDuplicateEntry) Error

func (e ErrDuplicateEntry) Error() string

type ErrFailedMigration

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

func (ErrFailedMigration) Error

func (e ErrFailedMigration) Error() string

func (ErrFailedMigration) Unwrap

func (e ErrFailedMigration) Unwrap() error

type ExecQuery

type ExecQuery interface {
	Exec(string, ...any) (sql.Result, error)
	Query(string, ...any) (*sql.Rows, error)
	QueryRow(string, ...any) *sql.Row
}

type Migrator

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

Migrator applies schema upgrades to the database

func FromDir

func FromDir(dir string) (Migrator, error)

Recursivly read migration files from directory

func (*Migrator) EnqueueMigrations

func (mig *Migrator) EnqueueMigrations() error

func (*Migrator) Execute

func (mig *Migrator) Execute(q ExecQuery) error

Executes the migration

func (*Migrator) FetchApplied

func (mig *Migrator) FetchApplied(q ExecQuery) error

func (Migrator) Initialize

func (mig Migrator) Initialize(q ExecQuery) error

Initialize the migration table in the database

func (*Migrator) InstallProgram

func (mig *Migrator) InstallProgram(fid fileIdentifier, program Program)

func (*Migrator) Next

func (mig *Migrator) Next() bool

True if there are migrations left to run

type Program

type Program func(q ExecQuery) error

Program is run after a migration file has been executed

Jump to

Keyboard shortcuts

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