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

Commit cee78cab by sdepold

use renameTableQuery skeleton

1 parent 2b553fe5
Showing with 27 additions and 19 deletions
...@@ -18,24 +18,6 @@ module.exports = (function() { ...@@ -18,24 +18,6 @@ module.exports = (function() {
return _query return _query
} }
QueryInterface.prototype.showAllTables = function() {
var self = this
return new Utils.CustomEventEmitter(function(emitter) {
self.sequelize.query('SHOW TABLES;', null, { raw: true }).success(function(data) {
var tableNames = Sequelize.Utils._.map(data, function(hash) {
return Sequelize.Utils._.values(hash)
})
self.emit('showAllTables', null)
emitter.emit('success', Sequelize.Utils._.flatten(tableNames))
}).error(function(err) {
self.emit('showAllTables', err)
emitter.emit('failure', err)
})
}).run()
}
QueryInterface.prototype.dropTable = function(tableName) { QueryInterface.prototype.dropTable = function(tableName) {
var _query = query.call(this, this.QueryGenerator.dropTableQuery(tableName)) var _query = query.call(this, this.QueryGenerator.dropTableQuery(tableName))
, self = this , self = this
...@@ -74,8 +56,34 @@ module.exports = (function() { ...@@ -74,8 +56,34 @@ module.exports = (function() {
}).run() }).run()
} }
QueryInterface.prototype.renameTable = function() { QueryInterface.prototype.renameTable = function(before, after) {
var _query = query.call(this, this.QueryGenerator.renameTableQuery(before, after))
, self = this
_query
.success(function(){ self.emit('renameTable', null) })
.error(function(err){ self.emit('renameTable', err)})
return _query
}
QueryInterface.prototype.showAllTables = function() {
var self = this
return new Utils.CustomEventEmitter(function(emitter) {
self.sequelize.query('SHOW TABLES;', null, { raw: true }).success(function(data) {
var tableNames = Sequelize.Utils._.map(data, function(hash) {
return Sequelize.Utils._.values(hash)
})
self.emit('showAllTables', null)
emitter.emit('success', Sequelize.Utils._.flatten(tableNames))
}).error(function(err) {
self.emit('showAllTables', err)
emitter.emit('failure', err)
})
}).run()
} }
QueryInterface.prototype.addColumn = function() { QueryInterface.prototype.addColumn = function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!