1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 14:20:54 +00:00

sort the reset

This commit is contained in:
astaxie 2014-08-14 11:44:10 +08:00
parent d2119f715c
commit 886bb782a5

View File

@ -174,22 +174,24 @@ func Rollback(name string) error {
// reset all migration // reset all migration
// run all migration's down function // run all migration's down function
func Reset() error { func Reset() error {
sm := sortMap(migrationMap)
i := 0 i := 0
for k, v := range migrationMap { for _, v := range sm {
if isRollBack(k) { if isRollBack(v.name) {
beego.Info("skip the", k) beego.Info("skip the", v.name)
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
continue continue
} }
beego.Info("start reset:", k) beego.Info("start reset:", v.name)
v.Down() v.m.Down()
err := v.Exec(k, "down") err := v.m.Exec(v.name, "down")
if err != nil { if err != nil {
beego.Error("execute error:", err) beego.Error("execute error:", err)
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
return err return err
} }
beego.Info("end reset:", k) i++
beego.Info("end reset:", v.name)
} }
beego.Info("total success reset:", i, " migration") beego.Info("total success reset:", i, " migration")
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)