Documentation
¶
Overview ¶
Package up provides a simple database migration tool.
Index ¶
Constants ¶
View Source
const ( RunTargetLatest = -1 RevertTargetInitial = 0 )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type FuncLoader ¶
type FuncLoader struct {
// contains filtered or unexported fields
}
FuncLoader is a Loader that loads a slice of Migrations.
func NewFuncLoader ¶
func NewFuncLoader(migrations ...*Migration) *FuncLoader
NewFuncLoader creates a new FuncLoader with the given migrations.
type Migration ¶
type Migration struct {
Version int64
Name string
RunFunc func(context.Context, *sql.DB) error
RevertFunc func(context.Context, *sql.DB) error
}
A Migration represents a schema change operation. Version indicates the migration's order in the change sequence. The Run and Revert functions are used to apply and revert the migration, respectively.
type Migrator ¶
type Migrator struct {
Store Store
Sources []*Migration
LogFunc func(s string)
DebugFunc func(s string)
HoldLockOnFailure bool
}
A Migrator stores migrations and provides methods to apply or revert them.
type Store ¶
type Store interface {
DB() *sql.DB
Init(context.Context) error
Lock(context.Context) error
Release(context.Context) error
Version(context.Context) (int64, error)
Insert(context.Context, int64) error
Remove(context.Context, int64) error
}
Store is an interface for a schema version store.
Directories
¶
| Path | Synopsis |
|---|---|
|
stores
|
|
|
sqlite3store
Package sqlite3store provides a SQLite3 implementation of the up.Store interface.
|
Package sqlite3store provides a SQLite3 implementation of the up.Store interface. |
Click to show internal directories.
Click to hide internal directories.