migrate

package
v1.93.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Graceful

func Graceful()

Graceful enables interrupts checking. Once the first ^C is received it will finish the currently running migration and abort execution of the next migration. If ^C is received twice, it will stop execution immediately.

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.

func NonGraceful

func NonGraceful()

NonGraceful disables interrupts checking. The first received ^C will stop execution immediately.

Types

type Migrator added in v1.91.0

type Migrator struct {
	Id       string
	Url      string
	Instance interface{}
	Path     string
	Store    file.FileStore
}

Read migration scripts from a given file store.

In order to use bindata asset as a store:

import "github.com/PlanitarInc/migrate/migrate"
import "github.com/PlanitarInc/migrate/file"
...
migrate.UseStore(file.AssetStore{
	Asset: Asset,
	AssetDir: AssetDir,
})

func (Migrator) Create added in v1.91.0

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

Create creates new migration files on disk

func (Migrator) Down added in v1.91.0

func (m Migrator) Down(pipe chan interface{})

Down rolls back all migrations

func (Migrator) DownSync added in v1.91.0

func (m Migrator) DownSync() (err []error, ok bool)

DownSync is synchronous version of Down

func (Migrator) Migrate added in v1.91.0

func (m Migrator) Migrate(pipe chan interface{}, relativeN int)

Migrate applies relative +n/-n migrations

func (Migrator) MigrateSync added in v1.91.0

func (m Migrator) MigrateSync(relativeN int) (err []error, ok bool)

MigrateSync is synchronous version of Migrate

func (Migrator) Redo added in v1.91.0

func (m Migrator) Redo(pipe chan interface{})

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

func (Migrator) RedoSync added in v1.91.0

func (m Migrator) RedoSync() (err []error, ok bool)

RedoSync is synchronous version of Redo

func (Migrator) Reset added in v1.91.0

func (m Migrator) Reset(pipe chan interface{})

Reset runs the down and up migration function

func (Migrator) ResetSync added in v1.91.0

func (m Migrator) ResetSync() (err []error, ok bool)

ResetSync is synchronous version of Reset

func (Migrator) Up added in v1.91.0

func (m Migrator) Up(pipe chan interface{})

Up applies all available migrations

func (Migrator) UpSync added in v1.91.0

func (m Migrator) UpSync() (err []error, ok bool)

UpSync is synchronous version of Up

func (Migrator) Version added in v1.91.0

func (m Migrator) Version() (version uint64, err error)

Version returns the current migration version

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.

Jump to

Keyboard shortcuts

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