Documentation ¶
Index ¶
- func MustRegister(fns ...func(DB) error)
- func MustRegisterTx(fns ...func(DB) error)
- func Register(fns ...func(DB) error) error
- func RegisterTx(fns ...func(DB) error) error
- func Run(db DB, a ...string) (oldVersion, newVersion int64, err error)
- func RunMigrations(db DB, migrations []Migration, a ...string) (oldVersion, newVersion int64, err error)
- func SetTableName(name string)
- func SetVersion(db DB, version int64) error
- func Version(db DB) (int64, error)
- type DB
- type Migration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRegister ¶
func MustRegisterTx ¶
func Register ¶
Register registers new database migration. Must be called from file with name like "1_initialize_db.go", where:
- 1 - migration version;
- initialize_db - comment.
func RegisterTx ¶
RegisterTx is just like Register but marks the migration to be executed inside a transaction.
func Run ¶
Run runs command on the db. Supported commands are: - up [target] - runs all available migrations by default or up to target one if argument is provided. - down - reverts last migration. - reset - reverts all migrations. - version - prints current db version. - set_version - sets db version without running migrations.
func RunMigrations ¶
func RunMigrations(db DB, migrations []Migration, a ...string) (oldVersion, newVersion int64, err error)
RunMigrations is like Run, but accepts list of migrations.
func SetTableName ¶
func SetTableName(name string)
func SetVersion ¶
Types ¶
type Migration ¶
func RegisteredMigrations ¶
func RegisteredMigrations() []Migration
RegisteredMigrations returns currently registered Migrations.
Click to show internal directories.
Click to hide internal directories.