不要怂,就是干,撸起袖子干!

Commit c17a6c71 by sdepold

method for checking the availability of interface calls in a migration method

1 parent b8cca92c
Showing with 26 additions and 5 deletions
...@@ -47,15 +47,35 @@ module.exports = (function() { ...@@ -47,15 +47,35 @@ module.exports = (function() {
method: 'up' method: 'up'
}, options || {}) }, options || {})
extendMigrationWithQueryInterfaceMethods.call(self, function allMethodsDone() { var onSuccess = function() { emitter.emit('success', null) }
emitter.emit('success', null) , func = self.migration[options.method]
})
var methods = require(self.path) extendMigrationWithQueryInterfaceMethods.call(self, onSuccess)
methods[options.method].call(null, self, DataTypes) func.call(null, self, DataTypes)
if(!self.migrationHasInterfaceCalls(func))
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('\\.' + 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
...@@ -106,5 +126,6 @@ module.exports = (function() { ...@@ -106,5 +126,6 @@ module.exports = (function() {
} }
} }
return Migration return Migration
})() })()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!