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 434b85a1
authored
Dec 07, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added options for running query chainer serialized
1 parent
058666ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
9 deletions
lib/migrator.js
lib/query-chainer.js
lib/migrator.js
View file @
434b85a
...
...
@@ -40,11 +40,11 @@ module.exports = (function() {
migrations
.
reverse
()
migrations
.
forEach
(
function
(
migration
)
{
chainer
.
add
(
migration
.
execute
(
options
)
)
chainer
.
add
(
migration
,
'execute'
,
[
options
]
)
})
chainer
.
run
()
.
run
Serial
()
.
success
(
function
()
{
emitter
.
emit
(
'success'
,
null
)
})
.
error
(
function
(
err
)
{
emitter
.
emit
(
'failure'
,
err
)
})
}
...
...
@@ -70,6 +70,10 @@ module.exports = (function() {
return
new
Migration
(
self
,
self
.
options
.
path
+
'/'
+
file
)
})
migrations
=
migrations
.
sort
(
function
(
a
,
b
){
return
parseInt
(
a
.
filename
.
split
(
'-'
)[
0
])
-
parseInt
(
b
.
filename
.
split
(
'-'
)[
0
])
})
if
(
this
.
options
.
from
)
{
filterFrom
(
migrations
,
this
.
options
.
from
,
function
(
err
,
migrations
)
{
if
(
self
.
options
.
to
)
...
...
lib/query-chainer.js
View file @
434b85a
...
...
@@ -6,6 +6,7 @@ module.exports = (function() {
this
.
finishedEmits
=
0
this
.
emitters
=
[]
this
.
serials
=
[]
this
.
fails
=
[]
this
.
finished
=
false
this
.
wasRunning
=
false
...
...
@@ -16,9 +17,14 @@ module.exports = (function() {
}
Utils
.
addEventEmitter
(
QueryChainer
)
QueryChainer
.
prototype
.
add
=
function
(
emitter
)
{
observeEmitter
.
call
(
this
,
emitter
)
this
.
emitters
.
push
(
emitter
)
QueryChainer
.
prototype
.
add
=
function
(
emitterOrKlass
,
method
,
params
)
{
if
(
!!
method
)
{
this
.
serials
.
push
({
klass
:
emitterOrKlass
,
method
:
method
,
params
:
params
})
}
else
{
observeEmitter
.
call
(
this
,
emitterOrKlass
)
this
.
emitters
.
push
(
emitterOrKlass
)
}
return
this
}
...
...
@@ -31,6 +37,33 @@ module.exports = (function() {
return
this
.
eventEmitter
.
run
()
}
QueryChainer
.
prototype
.
runSerial
=
function
()
{
var
self
=
this
var
exec
=
function
()
{
var
serial
=
self
.
serials
.
pop
()
if
(
serial
)
{
var
emitter
=
serial
.
klass
[
serial
.
method
].
apply
(
serial
.
klass
,
serial
.
params
)
emitter
.
success
(
function
()
{
self
.
finishedEmits
++
exec
()
}).
error
(
function
(
err
)
{
self
.
finishedEmits
++
self
.
fails
.
push
(
err
)
exec
()
})
}
else
{
self
.
wasRunning
=
true
finish
.
call
(
self
)
}
}
this
.
serials
.
reverse
()
this
.
eventEmitter
=
new
Utils
.
CustomEventEmitter
(
exec
)
return
this
.
eventEmitter
.
run
()
}
// private
var
observeEmitter
=
function
(
emitter
)
{
...
...
@@ -47,11 +80,18 @@ module.exports = (function() {
})
}
var
finish
=
function
(
result
)
{
this
.
finished
=
(
this
.
finishedEmits
==
this
.
emitters
.
length
)
var
finish
=
function
()
{
this
.
finished
=
true
if
(
this
.
emitters
.
length
>
0
)
this
.
finished
=
(
this
.
finishedEmits
==
this
.
emitters
.
length
)
else
if
(
this
.
serials
.
length
>
0
)
this
.
finished
=
(
this
.
finishedEmits
==
this
.
serials
.
length
)
if
(
this
.
finished
&&
this
.
wasRunning
)
{
var
status
=
this
.
fails
.
length
==
0
?
'success'
:
'failure'
result
=
this
.
fails
.
length
==
0
?
result
:
this
.
fails
var
status
=
(
this
.
fails
.
length
==
0
?
'success'
:
'failure'
)
,
result
=
(
this
.
fails
.
length
==
0
?
result
:
this
.
fails
)
this
.
eventEmitter
.
emit
(
status
,
result
)
}
}
...
...
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