Simple migration capabilities for any Go backend
|
пре 10 месеци | |
---|---|---|
.github | пре 10 месеци | |
.gitignore | пре 10 месеци | |
LICENSE.md | пре 10 месеци | |
README.md | пре 10 месеци | |
error.go | пре 10 месеци | |
func_migration.go | пре 10 месеци | |
go.mod | пре 10 месеци | |
interfaces.go | пре 10 месеци | |
module.go | пре 10 месеци | |
module_test.go | пре 10 месеци |
This package provides simple migration capabilities for any backend.
The key type in this package is Module
which allows mapping version strings to Migration
interfaces. For example:
import "github.com/annybs/migres"
type MyBackend struct{}
func (mb *MyBackend) Module() migres.Module {
return migres.Module{
"1.0.0": migres.Func(mb.upgradeV1, mb.downgradeV1),
"2.0.0": migres.Func(mb.upgradeV2, mb.downgradeV2),
}
}
Call Module.Upgrade(from, to)
or Module.Downgrade(from, to)
in order to execute migrations. The module ensures migrations are all run in the correct order.
See LICENSE.md