Limit foreign key creation current connector
Updated fk generation to make sure that it doesn't try to create foreign keys linking to another DB/connector
This commit is contained in:
parent
4d20fa7746
commit
d461d07f34
|
@ -418,16 +418,20 @@ function mixinMigration(MySQL, mysql) {
|
|||
//TODO validate that these are in the same DB, etc.
|
||||
//TODO this is probably a better place to check this than in autoupdate or buildColumnDefinitions
|
||||
var definition = this.getModelDefinition(model);
|
||||
|
||||
var fk = definition.settings.foreignKeys[keyName];
|
||||
if (fk) {
|
||||
var fkEntity = typeof fk.entity === 'object' ? fk.entity : {name: fk.entity}; //this.getModelDefinition(fk.entity);
|
||||
//get the definition of the referenced object
|
||||
var fkEntityName = (typeof fk.entity === 'object') ? fk.entity.name : fk.entity;
|
||||
|
||||
//TODO verify that the other model in the same DB
|
||||
//verify that the other model in the same DB
|
||||
if (this._models[fkEntityName]) {
|
||||
return ' CONSTRAINT ' + this.client.escapeId(fk.name) +
|
||||
' FOREIGN KEY (' + fk.foreignKey + ')' +
|
||||
' REFERENCES ' + this.tableEscaped(fkEntity.name) +
|
||||
' REFERENCES ' + this.tableEscaped(fkEntityName) +
|
||||
'(' + this.client.escapeId(fk.entityKey) + ')';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue