Documentation ¶
Overview ¶
Package migrate is imported by other Go code. It is the entry point to all migration functions.
Index ¶
- Constants
- func NewPipe() chan interface{}
- type Migrator
- func (m *Migrator) Create(incMajor bool, name string, contents ...string) (*file.MigrationFile, error)
- func (m *Migrator) Down(ctx context.Context, pipe chan interface{}, conn driver.Conn)
- func (m *Migrator) DownSync(ctx context.Context, conn driver.Conn) []error
- func (m *Migrator) Dump(ctx context.Context, pipe chan interface{}, conn driver.CopyConn, ...)
- func (m *Migrator) DumpSync(ctx context.Context, conn driver.CopyConn, dw file.DumpWriter) []error
- func (m *Migrator) Migrate(ctx context.Context, pipe chan interface{}, conn driver.Conn, relativeN int)
- func (m *Migrator) MigrateBetween(ctx context.Context, pipe chan interface{}, conn driver.Conn) (curVersion, dstVersion file.Version)
- func (m *Migrator) MigrateBetweenSync(ctx context.Context, conn driver.Conn) (curVersion, dstVersion file.Version, errs []error)
- func (m *Migrator) MigrateFiles(ctx context.Context, pipe chan interface{}, conn driver.Conn, ...)
- func (m *Migrator) MigrateSync(ctx context.Context, conn driver.Conn, relativeN int) []error
- func (m *Migrator) MigrateTo(ctx context.Context, pipe chan interface{}, conn driver.Conn, ...) (version file.Version)
- func (m *Migrator) MigrateToSync(ctx context.Context, conn driver.Conn, dstVersion file.Version) (version file.Version, errs []error)
- func (m *Migrator) Redo(ctx context.Context, pipe chan interface{}, conn driver.Conn)
- func (m *Migrator) RedoSync(ctx context.Context, conn driver.Conn) []error
- func (m *Migrator) Reset(ctx context.Context, pipe chan interface{}, conn driver.Conn)
- func (m *Migrator) ResetSync(ctx context.Context, conn driver.Conn) []error
- func (m *Migrator) Restore(ctx context.Context, pipe chan interface{}, conn driver.CopyConn, ...)
- func (m *Migrator) RestoreSync(ctx context.Context, conn driver.CopyConn, dr file.DumpReader) []error
- func (m *Migrator) SearchPath() string
- func (m *Migrator) Up(ctx context.Context, pipe chan interface{}, conn driver.Conn)
- func (m *Migrator) UpSync(ctx context.Context, conn driver.Conn) []error
- func (m *Migrator) Version(ctx context.Context, conn driver.Conn) (version file.Version, err error)
Constants ¶
const SchemaDir = "schema/"
SchemaDir is the dir used to store schema migrations in dump files
Variables ¶
This section is empty.
Functions ¶
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) 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
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
Redo rolls back the most recently applied migration, then runs it again.
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
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. |