migrate

package module
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

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

Handle encapsulates migrations functionality

func New

func New(drv driver.Driver, migrationsPath string, opts ...Option) (*Handle, error)

New migrations Handle

func Open

func Open(url, migrationsPath string, opts ...Option) (*Handle, error)

Open migrations Handle

func (*Handle) ApplyVersion

func (m *Handle) ApplyVersion(ctx context.Context, version file.Version) error

ApplyVersion applies specific version.

func (*Handle) Close

func (m *Handle) Close() error

Close database connection

func (*Handle) Create

func (m *Handle) Create(name string) (*file.MigrationFile, error)

Create creates new migration files on disk.

func (*Handle) Down

func (m *Handle) Down(ctx context.Context) error

Down rolls back all migrations.

func (*Handle) Migrate

func (m *Handle) Migrate(ctx context.Context, relativeN int) error

Migrate applies relative +n/-n migrations.

func (*Handle) PendingMigrations

func (m *Handle) PendingMigrations(ctx context.Context) (file.Files, error)

PendingMigrations returns list of pending migration files

func (*Handle) Redo

func (m *Handle) Redo(ctx context.Context) error

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

func (*Handle) Reset

func (m *Handle) Reset(ctx context.Context) error

Reset runs the Down and Up migration function.

func (*Handle) RollbackVersion

func (m *Handle) RollbackVersion(ctx context.Context, version file.Version) error

RollbackVersion runs `down` migration for specific version.

func (*Handle) Up

func (m *Handle) Up(ctx context.Context) error

Up applies all available migrations.

func (*Handle) Version

func (m *Handle) Version(ctx context.Context) (version file.Version, err error)

Version returns the current migration version.

func (*Handle) Versions

func (m *Handle) Versions(ctx context.Context) (versions file.Versions, err error)

Versions returns applied versions.

type Option

type Option func(h *Handle) error

Option for New

func WithHooks

func WithHooks(pre, post func(f file.File) error) Option

WithHooks allows to add pre/post migration hooks.

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 driver holds the driver interface.
Package driver holds the driver interface.
Package file contains functions for low-level migration files handling.
Package file contains functions for low-level migration files handling.

Jump to

Keyboard shortcuts

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