Handle undefined when altering tables
This commit is contained in:
parent
5f007eabc0
commit
1bae8a8062
|
@ -403,11 +403,13 @@ MySQL.prototype.alterTable = function (model, actualFields, actualIndexes, done,
|
||||||
propNames.forEach(function (propName) {
|
propNames.forEach(function (propName) {
|
||||||
if (propName === 'id') return;
|
if (propName === 'id') return;
|
||||||
var found;
|
var found;
|
||||||
|
if (actualIndexes) {
|
||||||
actualFields.forEach(function (f) {
|
actualFields.forEach(function (f) {
|
||||||
if (f.Field === propName) {
|
if (f.Field === propName) {
|
||||||
found = f;
|
found = f;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
actualize(propName, found);
|
actualize(propName, found);
|
||||||
|
@ -417,6 +419,7 @@ MySQL.prototype.alterTable = function (model, actualFields, actualIndexes, done,
|
||||||
});
|
});
|
||||||
|
|
||||||
// drop columns
|
// drop columns
|
||||||
|
if (actualFields) {
|
||||||
actualFields.forEach(function (f) {
|
actualFields.forEach(function (f) {
|
||||||
var notFound = !~propNames.indexOf(f.Field);
|
var notFound = !~propNames.indexOf(f.Field);
|
||||||
if (f.Field === 'id') return;
|
if (f.Field === 'id') return;
|
||||||
|
@ -424,6 +427,7 @@ MySQL.prototype.alterTable = function (model, actualFields, actualIndexes, done,
|
||||||
sql.push('DROP COLUMN `' + f.Field + '`');
|
sql.push('DROP COLUMN `' + f.Field + '`');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// remove indexes
|
// remove indexes
|
||||||
aiNames.forEach(function (indexName) {
|
aiNames.forEach(function (indexName) {
|
||||||
|
|
Loading…
Reference in New Issue