migrate

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package migrate manage DB migrations.

Index

Constants

This section is empty.

Variables

View Source
var ErrDownNotSupported = errors.New("downgrade is not supported, restore from backup instead")

ErrDownNotSupported must be returned from goose Down function in case this migration does not support downgrade.

Functions

func MySQLUpDownTest added in v0.4.0

func MySQLUpDownTest(t *check.C, ctx Ctx, goose *goosepkg.Instance, dir string, cfg *mysql.Config)

MySQLUpDownTest creates temporary database, test given migrations, and removes temporary database.

func PostgresUpDownTest added in v0.4.0

func PostgresUpDownTest(t *check.C, ctx Ctx, goose *goosepkg.Instance, dir string, cfg *def.PostgresConfig)

PostgresUpDownTest creates temporary database, test given migrations, and removes temporary database.

func Run

func Run(ctx Ctx, goose *goosepkg.Instance, dir string, command string, c Connector) error

Run executes goose command. It also enforce "fix" after "create".

func UpTo

func UpTo(ctx Ctx, goose *goosepkg.Instance, dir string, version int64, c Connector) (*schemaver.SchemaVer, error)

UpTo migrates up to a specific version.

Unlike goose.UpTo it will return error is current version doesn't match requested one after migration.

Types

type Connector added in v0.4.0

type Connector interface {
	Connect(Ctx, *goosepkg.Instance) (*sql.DB, *schemaver.SchemaVer, error)
}

Connector provides a way to connect to any database with schemaver.

type Ctx

type Ctx = context.Context

Ctx is a synonym for convenience.

type MySQL added in v0.4.0

type MySQL struct {
	*mysql.Config
}

MySQL implements Connector interface.

func (*MySQL) Connect added in v0.4.0

func (c *MySQL) Connect(ctx Ctx, goose *goosepkg.Instance) (_ *sql.DB, _ *schemaver.SchemaVer, err error)

Connect to MySQL. Will create database and initialize schemaver if needed.

type Postgres added in v0.4.0

type Postgres struct {
	*def.PostgresConfig
}

Postgres implements Connector interface.

func (*Postgres) Connect added in v0.4.0

func (c *Postgres) Connect(ctx Ctx, goose *goosepkg.Instance) (_ *sql.DB, _ *schemaver.SchemaVer, err error)

Connect to PostgreSQL. Will initialize schemaver if needed.

Jump to

Keyboard shortcuts

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