mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 23:01:28 +00:00
beego hook change the path & fix the migration bug
This commit is contained in:
parent
d325a66fee
commit
5ecfe0c335
5
beego.go
5
beego.go
@ -388,6 +388,9 @@ func initBeforeHttpRun() {
|
|||||||
Get("/docs", serverDocs)
|
Get("/docs", serverDocs)
|
||||||
Get("/docs/*", serverDocs)
|
Get("/docs/*", serverDocs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//init mime
|
||||||
|
AddAPPStartHook(initMime)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function is for test package init
|
// this function is for test package init
|
||||||
@ -406,6 +409,4 @@ func TestBeegoInit(apppath string) {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
hooks = make([]hookfunc, 0)
|
hooks = make([]hookfunc, 0)
|
||||||
//init mime
|
|
||||||
AddAPPStartHook(initMime)
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ package migration
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ func (m *Migration) Exec(name, status string) error {
|
|||||||
return m.addOrUpdateRecord(name, status)
|
return m.addOrUpdateRecord(name, status)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Migration) addOrUpdateRecord(status, name string) error {
|
func (m *Migration) addOrUpdateRecord(name, status string) error {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
if status == "down" {
|
if status == "down" {
|
||||||
status = "rollback"
|
status = "rollback"
|
||||||
@ -94,11 +95,11 @@ func (m *Migration) addOrUpdateRecord(status, name string) error {
|
|||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
status = "update"
|
status = "update"
|
||||||
p, err := o.Raw("insert into migrations(`name`,`created_at`,`statements`,`status`) values(?,?,?,?)").Prepare()
|
p, err := o.Raw("insert into migrations(`name`, `created_at`, `statements`, `status`) values(?,?,?,?)").Prepare()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = p.Exec(name, m.GetCreated(), strings.Join(m.sqls, "; "), status)
|
_, err = p.Exec(name, strconv.FormatInt(m.GetCreated(), 10), strings.Join(m.sqls, "; "), status)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user