Use table name instead of model name

This commit is contained in:
Raymond Feng 2014-09-10 23:45:27 -07:00
parent c35a00b808
commit 8a0ccf3ce3
1 changed files with 6 additions and 4 deletions

View File

@ -652,8 +652,9 @@ MySQL.prototype.autoupdate = function (models, cb) {
async.each(models, function (model, done) {
if (model in self._models) {
self.query('SHOW FIELDS FROM ' + self.tableEscaped(model), function (err, fields) {
self.query('SHOW INDEXES FROM ' + self.tableEscaped(model), function (err, indexes) {
var table = self.tableEscaped(model);
self.query('SHOW FIELDS FROM ' + table, function (err, fields) {
self.query('SHOW INDEXES FROM ' + table, function (err, indexes) {
if (!err && fields && fields.length) {
self.alterTable(model, fields, indexes, done);
} else {
@ -691,8 +692,9 @@ MySQL.prototype.isActual = function(cb) {
var self = this;
var ok = false;
async.each(Object.keys(this._models), function(model, done) {
self.query('SHOW FIELDS FROM ' + model, function(err, fields) {
self.query('SHOW INDEXES FROM ' + model, function(err, indexes) {
var table = self.tableEscaped(model);
self.query('SHOW FIELDS FROM ' + table, function(err, fields) {
self.query('SHOW INDEXES FROM ' + table, function(err, indexes) {
self.alterTable(model, fields, indexes, function(err, needAlter) {
if (err) {
return done(err);