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 680bdcc9
authored
Jun 25, 2013
by
freezy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added: Options containing pre/post/success functions.
1 parent
21286f12
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
lib/migrator.js
lib/migrator.js
View file @
680bdcc
...
...
@@ -167,16 +167,36 @@ module.exports = (function() {
}).
run
()
}
Migrator
.
prototype
.
execute
=
function
(
filename
)
{
/**
* Explicitly executes one or multiple migrations.
*
* @param filename {String|Array} Absolute filename(s) of the migrations script
* @param options {Object} Can contain three functions, before, after and success, which are executed before
* or after each migration respectively, with one parameter, the migration.
*/
Migrator
.
prototype
.
exec
=
function
(
filename
,
options
)
{
var
self
=
this
;
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
var
chainer
=
new
Utils
.
QueryChainer
;
var
addMigration
=
function
(
filename
)
{
self
.
options
.
logging
(
'Adding migration script at '
+
filename
)
self
.
options
.
logging
(
'Adding migration script at '
+
filename
)
var
migration
=
new
Migration
(
self
,
filename
)
chainer
.
add
(
migration
,
'execute'
,
[{
method
:
'up'
}],
{
before
:
function
(
migration
)
{
if
(
options
&&
Utils
.
_
.
isFunction
(
options
.
before
))
{
options
.
before
.
call
(
self
,
migration
);
}
},
after
:
function
(
migration
)
{
if
(
options
&&
Utils
.
_
.
isFunction
(
options
.
after
))
{
options
.
after
.
call
(
self
,
migration
);
}
},
success
:
function
(
migration
,
callback
)
{
if
(
options
&&
Utils
.
_
.
isFunction
(
options
.
success
))
{
options
.
success
.
call
(
self
,
migration
);
}
callback
();
}
})
...
...
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