Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
f98b1810
authored
2014-08-14 10:56:49 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update the reset
1 parent
55a77110
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
migration/migration.go
migration/migration.go
View file @
f98b181
...
...
@@ -45,7 +45,6 @@ type Migrationer interface {
var
(
migrationMap
map
[
string
]
Migrationer
SkipReset
[]
string
)
func
init
()
{
...
...
@@ -175,7 +174,7 @@ func Rollback(name string) error {
func
Reset
()
error
{
i
:=
0
for
k
,
v
:=
range
migrationMap
{
if
i
nSlice
(
k
,
SkipReset
)
{
if
i
sRollBack
(
k
)
{
beego
.
Info
(
"skip the"
,
k
)
continue
}
...
...
@@ -240,11 +239,19 @@ func sortMap(m map[string]Migrationer) dataSlice {
return
s
}
func
inSlice
(
key
string
,
sli
[]
string
)
bool
{
for
_
,
v
:=
range
sli
{
if
v
==
key
{
return
true
func
isRollBack
(
name
string
)
bool
{
o
:=
orm
.
NewOrm
()
var
maps
[]
orm
.
Params
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
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment