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 21286f12
authored
Jun 25, 2013
by
freezy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added execute() for direct migration per file.
1 parent
5cc12629
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
lib/migration.js
lib/migrator.js
lib/migration.js
View file @
21286f1
var
moment
=
require
(
"moment"
)
var
moment
=
require
(
"moment"
)
,
path
=
require
(
"path"
)
,
Utils
=
require
(
"./utils"
)
,
Utils
=
require
(
"./utils"
)
,
DataTypes
=
require
(
"./data-types"
)
,
DataTypes
=
require
(
"./data-types"
)
,
QueryInterface
=
require
(
"./query-interface"
)
,
QueryInterface
=
require
(
"./query-interface"
)
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
Migration
=
function
(
migrator
,
p
ath
)
{
var
Migration
=
function
(
migrator
,
p
)
{
this
.
migrator
=
migrator
this
.
migrator
=
migrator
this
.
path
=
path
this
.
path
=
path
.
normalize
(
p
)
this
.
filename
=
Utils
.
_
.
last
(
this
.
path
.
split
(
'/'
))
this
.
filename
=
Utils
.
_
.
last
(
this
.
path
.
split
(
path
.
sep
))
var
parsed
=
Migration
.
parseFilename
(
this
.
filename
)
var
parsed
=
Migration
.
parseFilename
(
this
.
filename
)
...
...
lib/migrator.js
View file @
21286f1
...
@@ -166,6 +166,36 @@ module.exports = (function() {
...
@@ -166,6 +166,36 @@ module.exports = (function() {
}
}
}).
run
()
}).
run
()
}
}
Migrator
.
prototype
.
execute
=
function
(
filename
)
{
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
)
var
migration
=
new
Migration
(
self
,
filename
)
chainer
.
add
(
migration
,
'execute'
,
[{
method
:
'up'
}],
{
success
:
function
(
migration
,
callback
)
{
callback
();
}
})
}
if
(
Utils
.
_
.
isArray
(
filename
))
{
Utils
.
_
.
each
(
filename
,
function
(
f
)
{
addMigration
(
f
);
})
}
else
{
addMigration
(
filename
);
}
chainer
.
runSerially
({
skipOnError
:
true
})
.
success
(
function
()
{
emitter
.
emit
(
'success'
,
null
)
})
.
error
(
function
(
err
)
{
emitter
.
emit
(
'error'
,
err
)
})
}).
run
()
}
// private
// private
...
...
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