Use table name instead of model name
This commit is contained in:
parent
c35a00b808
commit
8a0ccf3ce3
10
lib/mysql.js
10
lib/mysql.js
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue