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 3f6d2cf8
authored
Nov 23, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved method for getting undone migration files to public availability for better testing
1 parent
dd3ce15a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
lib/migrator.js
lib/migrator.js
View file @
3f6d2cf
...
...
@@ -21,13 +21,37 @@ module.exports = (function() {
var
self
=
this
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
getUndoneMigrations
.
call
(
self
,
function
(
migrations
)
{
self
.
getUndoneMigrations
(
function
(
migrations
)
{
emitter
.
emit
(
'success'
)
console
.
log
(
migrations
)
})
}).
run
()
}
Migrator
.
prototype
.
getUndoneMigrations
=
function
(
callback
)
{
var
undoneMigrations
=
fs
.
readdirSync
(
this
.
options
.
path
)
if
(
this
.
options
.
from
)
{
var
fromDate
=
stringToDate
(
this
.
options
.
from
.
toString
())
undoneMigrations
=
undoneMigrations
.
filter
(
function
(
file
)
{
var
fileDate
=
stringToDate
(
file
.
split
(
"-"
)[
0
])
return
(
fileDate
>=
fromDate
)
})
}
if
(
this
.
options
.
to
)
{
var
toDate
=
stringToDate
(
this
.
options
.
to
.
toString
())
undoneMigrations
=
undoneMigrations
.
filter
(
function
(
file
)
{
var
fileDate
=
stringToDate
(
file
.
split
(
"-"
)[
0
])
return
(
fileDate
<=
toDate
)
})
}
callback
&&
callback
(
undoneMigrations
)
}
// private
var
executeMigration
=
function
(
path
,
method
)
{
...
...
@@ -78,29 +102,5 @@ module.exports = (function() {
return
moment
(
getFormattedDateString
(
s
),
"YYYYMMDDHHmmss"
)
}
var
getUndoneMigrations
=
function
(
callback
)
{
var
migrationFiles
=
fs
.
readdirSync
(
this
.
options
.
path
)
,
undoneMigrations
=
migrationFiles
if
(
this
.
options
.
from
)
{
var
sinceDate
=
stringToDate
(
this
.
options
.
from
.
toString
())
undoneMigrations
=
migrationFiles
.
filter
(
function
(
file
)
{
var
fileDate
=
stringToDate
(
file
.
split
(
"-"
)[
0
])
return
fileDate
.
diff
(
sinceDate
)
>=
0
})
}
if
(
this
.
options
.
to
)
{
var
toDate
=
stringToDate
(
this
.
options
.
to
.
toString
())
undoneMigrations
=
undoneMigrations
.
filter
(
function
(
file
)
{
var
fileDate
=
stringToDate
(
file
.
split
(
"-"
)[
0
])
return
toDate
.
diff
(
fileDate
)
>=
0
})
}
callback
&&
callback
(
undoneMigrations
)
}
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