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 8a577d68
authored
Nov 24, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored SequelizeMeta getter
1 parent
2bd96dd0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
lib/migrator.js
lib/migrator.js
View file @
8a577d6
...
@@ -80,40 +80,46 @@ module.exports = (function() {
...
@@ -80,40 +80,46 @@ module.exports = (function() {
}
}
}
}
// private
Migrator
.
prototype
.
findOrCreateSequelizeMetaModel
=
function
(
syncOptions
)
{
var
executeMigration
=
function
(
path
,
method
)
{
var
migration
=
require
(
path
)
migration
[
method
||
'up'
](
this
.
queryInterface
,
DataTypes
)
}
var
getLastMigrationIdFromDatabase
=
function
()
{
var
self
=
this
var
self
=
this
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
var
SequelizeMeta
=
self
.
sequelize
.
modelManager
.
getModel
(
'SequelizeMeta'
)
var
SequelizeMeta
=
self
.
sequelize
.
modelManager
.
getModel
(
'SequelizeMeta'
)
var
findLastMigrationId
=
function
()
{
SequelizeMeta
.
find
({
order
:
'id DESC'
}).
success
(
function
(
sequelizeMeta
)
{
emitter
.
emit
(
'success'
,
sequelizeMeta
?
sequelizeMeta
.
lastMigrationId
:
null
)
}).
error
(
function
(
err
)
{
emitter
.
emit
(
'failure'
,
err
)
})
}
if
(
SequelizeMeta
)
{
if
(
SequelizeMeta
)
{
findLastMigrationId
(
)
emitter
.
emit
(
'success'
,
SequelizeMeta
)
}
else
{
}
else
{
SequelizeMeta
=
self
.
sequelize
.
define
(
'SequelizeMeta'
,
{
SequelizeMeta
=
self
.
sequelize
.
define
(
'SequelizeMeta'
,
{
lastMigrationId
:
DataTypes
.
STRING
lastMigrationId
:
DataTypes
.
STRING
})
})
SequelizeMeta
SequelizeMeta
.
sync
()
.
sync
(
syncOptions
||
{}
)
.
success
(
function
()
{
findLastMigrationId
(
)
})
.
success
(
function
()
{
emitter
.
emit
(
'success'
,
SequelizeMeta
)
})
.
error
(
function
(
err
)
{
emitter
.
emit
(
'failure'
,
err
)
})
.
error
(
function
(
err
)
{
emitter
.
emit
(
'failure'
,
err
)
})
}
}
}).
run
()
}).
run
()
}
}
// private
var
executeMigration
=
function
(
path
,
method
)
{
var
migration
=
require
(
path
)
migration
[
method
||
'up'
](
this
.
queryInterface
,
DataTypes
)
}
var
getLastMigrationIdFromDatabase
=
function
()
{
var
self
=
this
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
self
.
findOrCreateSequelizeMetaModel
().
success
(
function
(
SequelizeMeta
)
{
SequelizeMeta
.
find
({
order
:
'id DESC'
}).
success
(
function
(
meta
)
{
emitter
.
emit
(
'success'
,
meta
?
meta
.
lastMigrationId
:
null
)
}).
error
(
function
(
err
)
{
emitter
.
emit
(
'failure'
,
err
)
})
}).
error
(
function
(
err
)
{
emitter
.
emit
(
err
)
})
}).
run
()
}
var
getFormattedDateString
=
function
(
s
)
{
var
getFormattedDateString
=
function
(
s
)
{
var
result
=
null
var
result
=
null
...
...
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