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 8f84cc19
authored
Jan 07, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrationHasInterfaceCalls is now static function
1 parent
72c524c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
23 deletions
lib/migration.js
spec/migration.spec.js
lib/migration.js
View file @
8f84cc1
...
@@ -36,10 +36,28 @@ module.exports = (function() {
...
@@ -36,10 +36,28 @@ module.exports = (function() {
return
moment
(
Migration
.
getFormattedDateString
(
s
),
"YYYYMMDDHHmmss"
)
return
moment
(
Migration
.
getFormattedDateString
(
s
),
"YYYYMMDDHHmmss"
)
}
}
Migration
.
migrationHasInterfaceCalls
=
function
(
func
)
{
var
functionString
=
Utils
.
removeCommentsFromFunctionString
(
func
.
toString
())
,
hasCalls
=
false
for
(
var
method
in
QueryInterface
.
prototype
)
{
var
regex
=
new
RegExp
(
'[\\s\\n\\r]*\\.[\\s\\n\\r]*'
+
method
)
hasCalls
=
hasCalls
||
regex
.
test
(
functionString
)
}
return
hasCalls
}
///////////////
///////////////
// member /////
// member /////
///////////////
///////////////
Object
.
defineProperty
(
Migration
.
prototype
,
'migration'
,
{
get
:
function
()
{
return
require
(
this
.
path
)
}
})
Migration
.
prototype
.
execute
=
function
(
options
)
{
Migration
.
prototype
.
execute
=
function
(
options
)
{
var
self
=
this
var
self
=
this
...
@@ -54,29 +72,11 @@ module.exports = (function() {
...
@@ -54,29 +72,11 @@ module.exports = (function() {
extendMigrationWithQueryInterfaceMethods
.
call
(
self
,
onSuccess
)
extendMigrationWithQueryInterfaceMethods
.
call
(
self
,
onSuccess
)
func
.
call
(
null
,
self
,
DataTypes
)
func
.
call
(
null
,
self
,
DataTypes
)
if
(
!
self
.
migrationHasInterfaceCalls
(
func
))
if
(
!
Migration
.
migrationHasInterfaceCalls
(
func
))
onSuccess
()
onSuccess
()
}).
run
()
}).
run
()
}
}
Object
.
defineProperty
(
Migration
.
prototype
,
'migration'
,
{
get
:
function
()
{
return
require
(
this
.
path
)
}
})
Migration
.
prototype
.
migrationHasInterfaceCalls
=
function
(
func
)
{
var
functionString
=
Utils
.
removeCommentsFromFunctionString
(
func
.
toString
())
,
hasCalls
=
false
for
(
var
method
in
QueryInterface
.
prototype
)
{
var
regex
=
new
RegExp
(
'[\\s\\n\\r]*\\.[\\s\\n\\r]*'
+
method
)
hasCalls
=
hasCalls
||
regex
.
test
(
functionString
)
}
return
hasCalls
}
Migration
.
prototype
.
isBefore
=
function
(
dateString
,
options
)
{
Migration
.
prototype
.
isBefore
=
function
(
dateString
,
options
)
{
options
=
Utils
.
_
.
extend
({
options
=
Utils
.
_
.
extend
({
withoutEquals
:
false
withoutEquals
:
false
...
...
spec/migration.spec.js
View file @
8f84cc1
...
@@ -8,9 +8,6 @@ var config = require("./config/config")
...
@@ -8,9 +8,6 @@ var config = require("./config/config")
describe
(
'Migration'
,
function
()
{
describe
(
'Migration'
,
function
()
{
describe
(
'migrationHasInterfaceCalls'
,
function
()
{
describe
(
'migrationHasInterfaceCalls'
,
function
()
{
var
migrator
=
new
Migrator
(
sequelize
)
,
migration
=
new
Migration
(
migrator
,
'/var/lib/20111117063700-asd.js'
)
// the syntax in the following tests are correct
// the syntax in the following tests are correct
// don't touch them! the functions will get stringified below
// don't touch them! the functions will get stringified below
var
tests
=
[
var
tests
=
[
...
@@ -64,7 +61,7 @@ describe('Migration', function() {
...
@@ -64,7 +61,7 @@ describe('Migration', function() {
tests
.
forEach
(
function
(
test
)
{
tests
.
forEach
(
function
(
test
)
{
it
(
'correctly result in '
+
test
.
expectation
+
' for '
+
test
.
topic
.
toString
(),
function
()
{
it
(
'correctly result in '
+
test
.
expectation
+
' for '
+
test
.
topic
.
toString
(),
function
()
{
expect
(
m
igration
.
migrationHasInterfaceCalls
(
test
.
topic
)).
toEqual
(
test
.
expectation
)
expect
(
M
igration
.
migrationHasInterfaceCalls
(
test
.
topic
)).
toEqual
(
test
.
expectation
)
})
})
})
})
})
})
...
...
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