mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 15:10:55 +00:00
update the reset
This commit is contained in:
parent
55a7711017
commit
f98b1810ab
@ -45,7 +45,6 @@ type Migrationer interface {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
migrationMap map[string]Migrationer
|
migrationMap map[string]Migrationer
|
||||||
SkipReset []string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -175,7 +174,7 @@ 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) {
|
if isRollBack(k) {
|
||||||
beego.Info("skip the", k)
|
beego.Info("skip the", k)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -240,11 +239,19 @@ func sortMap(m map[string]Migrationer) dataSlice {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func inSlice(key string, sli []string) bool {
|
func isRollBack(name string) bool {
|
||||||
for _, v := range sli {
|
o := orm.NewOrm()
|
||||||
if v == key {
|
var maps []orm.Params
|
||||||
return true
|
num, err := o.Raw("select * from migrations where `name` = ? order by id desc", name).Values(&maps)
|
||||||
|
if err != nil {
|
||||||
|
beego.Info("get name has error", err)
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
if num <= 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if maps[0]["status"] == "rollback" {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user