Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
5ecfe0c3
Commit
5ecfe0c3
authored
Aug 13, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beego hook change the path & fix the migration bug
parent
d325a66f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
beego.go
beego.go
+3
-2
migration.go
migration/migration.go
+5
-4
No files found.
beego.go
View file @
5ecfe0c3
...
...
@@ -388,6 +388,9 @@ func initBeforeHttpRun() {
Get
(
"/docs"
,
serverDocs
)
Get
(
"/docs/*"
,
serverDocs
)
}
//init mime
AddAPPStartHook
(
initMime
)
}
// this function is for test package init
...
...
@@ -406,6 +409,4 @@ func TestBeegoInit(apppath string) {
func
init
()
{
hooks
=
make
([]
hookfunc
,
0
)
//init mime
AddAPPStartHook
(
initMime
)
}
migration/migration.go
View file @
5ecfe0c3
...
...
@@ -23,6 +23,7 @@ package migration
import
(
"errors"
"sort"
"strconv"
"strings"
"time"
...
...
@@ -82,11 +83,11 @@ func (m *Migration) Exec(name, status string) error {
return
m
.
addOrUpdateRecord
(
name
,
status
)
}
func
(
m
*
Migration
)
addOrUpdateRecord
(
status
,
name
string
)
error
{
func
(
m
*
Migration
)
addOrUpdateRecord
(
name
,
status
string
)
error
{
o
:=
orm
.
NewOrm
()
if
status
==
"down"
{
status
=
"rollback"
p
,
err
:=
o
.
Raw
(
"update migrations set status = ?,rollback_statements = ? where name = ?"
)
.
Prepare
()
p
,
err
:=
o
.
Raw
(
"update migrations set status = ?,
rollback_statements = ? where name = ?"
)
.
Prepare
()
if
err
!=
nil
{
return
nil
}
...
...
@@ -94,11 +95,11 @@ func (m *Migration) addOrUpdateRecord(status, name string) error {
return
err
}
else
{
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
{
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
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment