migrate

package module
v0.0.0-...-1af4f67 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 13 Imported by: 0

README

migrate moved to egt.run/migrate

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pledge

func Pledge() error

Pledge is only supported on OpenBSD.

func Unveil

func Unveil(paths []string) error

Unveil is only supported on OpenBSD.

Types

type Logger

type Logger interface {
	Printf(string, ...interface{})
	Println(...interface{})
}

type Migrate

type Migrate struct {
	Migrations []Migration
	Files      []os.FileInfo
	// contains filtered or unexported fields
}

func New

func New(
	db Store,
	log Logger,
	dir, skip string,
) (*Migrate, error)

func (*Migrate) Migrate

func (m *Migrate) Migrate() (bool, error)

Migrate all files in the directory. This function reports whether any migration took place.

type Migration

type Migration struct {
	Filename string
	Checksum string
	Content  string
}

type StdLogger

type StdLogger struct{}

StdLogger is a helper type that simply logs to stdout using fmt. Unless you want to structure logs or redirect them in some way, this is probably what you want to use in migrate.New().

func (StdLogger) Printf

func (l StdLogger) Printf(s string, vs ...interface{})

func (StdLogger) Println

func (l StdLogger) Println(vs ...interface{})

type Store

type Store interface {
	Open() error
	Exec(string, ...interface{}) (sql.Result, error)

	// CreateMetaversionIfNotExists and report the current version.
	CreateMetaVersionIfNotExists() (int, error)
	CreateMetaIfNotExists() error
	CreateMetaCheckpointsIfNotExists() error

	GetMigrations() ([]Migration, error)
	InsertMigration(filename, content, checksum string) error
	UpsertMigration(filename, content, checksum string) error

	GetMetaCheckpoints(string) ([]string, error)
	InsertMetaCheckpoint(filename, content, checksum string, idx int) error
	DeleteMetaCheckpoints() error

	UpgradeToV1([]Migration) error
}

Directories

Path Synopsis
cmd
migrate command

Jump to

Keyboard shortcuts

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