Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 55e8be8a
authored
Jan 23, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete SequelizeMeta database entry after undoing a migration
1 parent
6d1bd3fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
lib/migrator.js
lib/migrator.js
View file @
55e8be8
...
@@ -36,9 +36,12 @@ module.exports = (function() {
...
@@ -36,9 +36,12 @@ module.exports = (function() {
emitter
.
emit
(
'failure'
,
err
)
emitter
.
emit
(
'failure'
,
err
)
}
else
{
}
else
{
var
chainer
=
new
Utils
.
QueryChainer
var
chainer
=
new
Utils
.
QueryChainer
,
from
=
migrations
[
0
]
if
(
options
.
method
==
'down'
)
if
(
options
.
method
==
'down'
)
{
migrations
.
reverse
()
migrations
.
reverse
()
from
=
migrations
[
0
]
}
migrations
.
forEach
(
function
(
migration
)
{
migrations
.
forEach
(
function
(
migration
)
{
chainer
.
add
(
migration
,
'execute'
,
[
options
],
{
chainer
.
add
(
migration
,
'execute'
,
[
options
],
{
...
@@ -51,7 +54,10 @@ module.exports = (function() {
...
@@ -51,7 +54,10 @@ module.exports = (function() {
console
.
log
(
'Executed migration: '
+
migration
.
filename
)
console
.
log
(
'Executed migration: '
+
migration
.
filename
)
},
},
success
:
function
(
migration
,
callback
)
{
success
:
function
(
migration
,
callback
)
{
saveSuccessfulMigration
.
call
(
self
,
migrations
[
0
],
migration
,
callback
)
if
(
options
.
method
==
'down'
)
deleteUndoneMigration
.
call
(
self
,
from
,
migration
,
callback
)
else
saveSuccessfulMigration
.
call
(
self
,
from
,
migration
,
callback
)
}
}
})
})
})
})
...
@@ -195,5 +201,17 @@ module.exports = (function() {
...
@@ -195,5 +201,17 @@ module.exports = (function() {
})
})
}
}
var
deleteUndoneMigration
=
function
(
from
,
to
,
callback
)
{
var
self
=
this
self
.
findOrCreateSequelizeMetaModel
().
success
(
function
(
SequelizeMeta
)
{
SequelizeMeta
.
find
({
from
:
from
.
migrationId
,
to
:
to
.
migrationId
})
.
success
(
function
(
meta
)
{
meta
.
destroy
().
success
(
callback
)
})
})
}
return
Migrator
return
Migrator
})()
})()
Write
Preview
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