Added support for composite foreign keys in the ERD tool. Fixes #6891

This commit is contained in:
Aditya Toshniwal
2021-10-13 14:28:55 +05:30
committed by Akshay Joshi
parent 96ce298789
commit 8b7b63868f
5 changed files with 35 additions and 10 deletions

View File

@@ -256,7 +256,13 @@ export default class ForeignKeySchema extends BaseUISchema {
}
}
let oldindex = 'fki_'+actionObj.oldState.name;
let oldindex;
if(obj.inTable) {
let oldFk = _.get(actionObj.oldState, _.slice(actionObj.path, 0, -1));
oldindex = 'fki_'+oldFk.name;
} else {
oldindex = 'fki_'+actionObj.oldState.name;
}
if(state.hasindex) {
return {};
} else if(!state.autoindex) {

View File

@@ -352,6 +352,15 @@ export default class TableSchema extends BaseUISchema {
delete c.inheritedfromtable;
return c;
});
/* Make autoindex as true if there is coveringindex since ERD works in create mode */
newData.foreign_key = (newData.foreign_key||[]).map((fk)=>{
fk.autoindex = false;
if(fk.coveringindex) {
fk.autoindex = true;
}
return fk;
});
return newData;
}