migrate

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package migrate is imported by other Go code. It is the entry point to all migration functions.

Index

Constants

View Source
const SchemaDir = "schema/"

SchemaDir is the dir used to store schema migrations in dump files

Variables

This section is empty.

Functions

func NewPipe

func NewPipe() chan interface{}

NewPipe is a convenience function for pipe.New(). This is helpful if the user just wants to import this package and nothing else.

Types

type Migrator added in v1.3.0

type Migrator struct {
	Driver driver.Driver
	// Path for schema migrations.
	Path string
	// // Path for storing executed migrations that are used for validation and for downgrading when the versions don't exist in MigrationsPath
	// PrevPath string
	// True if a transaction should be used for each file instead of per each major version
	TxPerFile bool
	// True if the migration should be interruptable
	Interrupts bool
	// Don't validate base upfiles
	Force bool
	// Schema to use
	Schema string
	// ExtraSchemas to put in search path
	ExtraSchemas []string
}

Migrator struct

func (*Migrator) Create added in v1.3.0

func (m *Migrator) Create(incMajor bool, name string, contents ...string) (*file.MigrationFile, error)

Create creates new migration files on disk

func (*Migrator) Down added in v1.3.0

func (m *Migrator) Down(ctx context.Context, pipe chan interface{}, conn driver.Conn)

Down rolls back all migrations

func (*Migrator) DownSync added in v1.3.0

func (m *Migrator) DownSync(ctx context.Context, conn driver.Conn) []error

DownSync is synchronous version of Down

func (*Migrator) Dump added in v1.3.0

func (m *Migrator) Dump(ctx context.Context, pipe chan interface{}, conn driver.CopyConn, dw file.DumpWriter)

func (*Migrator) DumpSync added in v1.3.0

func (m *Migrator) DumpSync(ctx context.Context, conn driver.CopyConn, dw file.DumpWriter) []error

DumpSync is synchronous version of Dump

func (*Migrator) Migrate added in v1.3.0

func (m *Migrator) Migrate(ctx context.Context, pipe chan interface{}, conn driver.Conn, relativeN int)

Migrate applies relative +n/-n migrations

func (*Migrator) MigrateBetween added in v1.3.0

func (m *Migrator) MigrateBetween(ctx context.Context, pipe chan interface{}, conn driver.Conn) (curVersion, dstVersion file.Version)

MigrateBetween migrates to the destination version

func (*Migrator) MigrateBetweenSync added in v1.3.0

func (m *Migrator) MigrateBetweenSync(ctx context.Context, conn driver.Conn) (curVersion, dstVersion file.Version, errs []error)

MigrateBetweenSync is synchronous version of MigrateBetween

func (*Migrator) MigrateFiles added in v1.3.0

func (m *Migrator) MigrateFiles(ctx context.Context, pipe chan interface{}, conn driver.Conn, prevFiles, files file.MigrationFiles, applyMigrations file.Migrations)

MigrateFiles applies migrations in given files

func (*Migrator) MigrateSync added in v1.3.0

func (m *Migrator) MigrateSync(ctx context.Context, conn driver.Conn, relativeN int) []error

MigrateSync is synchronous version of Migrate

func (*Migrator) MigrateTo added in v1.3.0

func (m *Migrator) MigrateTo(ctx context.Context, pipe chan interface{}, conn driver.Conn, dstVersion file.Version) (version file.Version)

MigrateTo migrates to the destination version

func (*Migrator) MigrateToSync added in v1.3.0

func (m *Migrator) MigrateToSync(ctx context.Context, conn driver.Conn, dstVersion file.Version) (version file.Version, errs []error)

MigrateToSync is synchronous version of MigrateTo

func (*Migrator) Redo added in v1.3.0

func (m *Migrator) Redo(ctx context.Context, pipe chan interface{}, conn driver.Conn)

Redo rolls back the most recently applied migration, then runs it again.

func (*Migrator) RedoSync added in v1.3.0

func (m *Migrator) RedoSync(ctx context.Context, conn driver.Conn) []error

RedoSync is synchronous version of Redo

func (*Migrator) Reset added in v1.3.0

func (m *Migrator) Reset(ctx context.Context, pipe chan interface{}, conn driver.Conn)

Reset runs the down and up migration function

func (*Migrator) ResetSync added in v1.3.0

func (m *Migrator) ResetSync(ctx context.Context, conn driver.Conn) []error

ResetSync is synchronous version of Reset

func (*Migrator) Restore added in v1.3.0

func (m *Migrator) Restore(ctx context.Context, pipe chan interface{}, conn driver.CopyConn, dr file.DumpReader)

func (*Migrator) RestoreSync added in v1.3.0

func (m *Migrator) RestoreSync(ctx context.Context, conn driver.CopyConn, dr file.DumpReader) []error

RestoreSync is synchronous version of Restore

func (*Migrator) SearchPath added in v1.4.0

func (m *Migrator) SearchPath() string

func (*Migrator) Up added in v1.3.0

func (m *Migrator) Up(ctx context.Context, pipe chan interface{}, conn driver.Conn)

Up applies all available migrations

func (*Migrator) UpSync added in v1.3.0

func (m *Migrator) UpSync(ctx context.Context, conn driver.Conn) []error

UpSync is synchronous version of Up

func (*Migrator) Version added in v1.3.0

func (m *Migrator) Version(ctx context.Context, conn driver.Conn) (version file.Version, err error)

Directories

Path Synopsis
Package direction just holds convenience constants for Up and Down migrations.
Package direction just holds convenience constants for Up and Down migrations.
Package txtype just holds constants for per file and single transaction types.
Package txtype just holds constants for per file and single transaction types.

Jump to

Keyboard shortcuts

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