55a77110 by astaxie

migration: skip reset

1 parent 436edda9
......@@ -43,7 +43,10 @@ type Migrationer interface {
GetCreated() int64
}
var migrationMap map[string]Migrationer
var (
migrationMap map[string]Migrationer
SkipReset []string
)
func init() {
migrationMap = make(map[string]Migrationer)
......@@ -172,6 +175,10 @@ func Rollback(name string) error {
func Reset() error {
i := 0
for k, v := range migrationMap {
if inSlice(k, SkipReset) {
beego.Info("skip the", k)
continue
}
beego.Info("start reset:", k)
v.Down()
err := v.Exec(k, "down")
......@@ -232,3 +239,12 @@ func sortMap(m map[string]Migrationer) dataSlice {
sort.Sort(s)
return s
}
func inSlice(key string, sli []string) bool {
for _, v := range sli {
if v == key {
return true
}
}
return false
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!