Help us shape the future of Go! Take the 2026 Go Developer Survey

gomig

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package gomig TODO: add documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoBackend returned by runners if no BackendAdapter set
	ErrNoBackend = errors.New("NO_BACKEND")
	// ErrNoMigrations returns by NewRunner if no migrations provided
	ErrNoMigrations = errors.New("NO_MIGRATIONS")
	// ErrMigrationFailed returned by runners if migration was failed
	ErrMigrationFailed = errors.New("MIGRATION_FAILED")
)

Functions

This section is empty.

Types

type BackendAdapter

type BackendAdapter interface {
	GetVersion(ctx context.Context) (uint, error)
	SaveVersion(ctx context.Context, ver uint, name string, messages []string) error
	Reset(ctx context.Context) error
}

BackendAdapter TODO: Add documentation

type Migration

type Migration interface {
	Up(ctx context.Context) (messages []string, err error)
	Down(ctx context.Context) (messages []string, err error)
	Name() string
}

Migration TODO: Add documentation

type Runner

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

Runner the runner of migrations

func NewRunner

func NewRunner(migs []Migration, storage BackendAdapter) *Runner

NewRunner creates the runner

func (*Runner) Down added in v0.0.6

func (r *Runner) Down(ctx context.Context) error

func (*Runner) ForceVer

func (r *Runner) ForceVer(ctx context.Context, ver uint) error

ForceVer calls Reset then runs migrations up to the ver number

func (*Runner) Reset

func (r *Runner) Reset(ctx context.Context) error

Reset runs all migrations down to the clean state and calls to Reset of storage

func (*Runner) SetVer

func (r *Runner) SetVer(ctx context.Context, ver uint) error

SetVer runs migrations up or down to the ver number

func (*Runner) Up added in v0.0.6

func (r *Runner) Up(ctx context.Context) error

Up runs the migrations from the current version up to the latest

Jump to

Keyboard shortcuts

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