mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 08:00:54 +00:00
migration: skip reset
This commit is contained in:
parent
436edda926
commit
55a7711017
@ -43,7 +43,10 @@ type Migrationer interface {
|
|||||||
GetCreated() int64
|
GetCreated() int64
|
||||||
}
|
}
|
||||||
|
|
||||||
var migrationMap map[string]Migrationer
|
var (
|
||||||
|
migrationMap map[string]Migrationer
|
||||||
|
SkipReset []string
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
migrationMap = make(map[string]Migrationer)
|
migrationMap = make(map[string]Migrationer)
|
||||||
@ -172,6 +175,10 @@ func Rollback(name string) error {
|
|||||||
func Reset() error {
|
func Reset() error {
|
||||||
i := 0
|
i := 0
|
||||||
for k, v := range migrationMap {
|
for k, v := range migrationMap {
|
||||||
|
if inSlice(k, SkipReset) {
|
||||||
|
beego.Info("skip the", k)
|
||||||
|
continue
|
||||||
|
}
|
||||||
beego.Info("start reset:", k)
|
beego.Info("start reset:", k)
|
||||||
v.Down()
|
v.Down()
|
||||||
err := v.Exec(k, "down")
|
err := v.Exec(k, "down")
|
||||||
@ -232,3 +239,12 @@ func sortMap(m map[string]Migrationer) dataSlice {
|
|||||||
sort.Sort(s)
|
sort.Sort(s)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func inSlice(key string, sli []string) bool {
|
||||||
|
for _, v := range sli {
|
||||||
|
if v == key {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user