|
|
@ -1754,6 +1754,31 @@ const deleteHmOrBtRelation = async ( |
|
|
|
}, |
|
|
|
}, |
|
|
|
ignoreFkDelete = false |
|
|
|
ignoreFkDelete = false |
|
|
|
) => { |
|
|
|
) => { |
|
|
|
|
|
|
|
let foreignKeyName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if relationColOpt is not provided, extract it from child table
|
|
|
|
|
|
|
|
// and get the foreign key name for dropping the foreign key
|
|
|
|
|
|
|
|
if (!relationColOpt) { |
|
|
|
|
|
|
|
foreignKeyName = ( |
|
|
|
|
|
|
|
( |
|
|
|
|
|
|
|
await childTable.getColumns().then((cols) => { |
|
|
|
|
|
|
|
return cols?.find((c) => { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
|
|
|
|
c.colOptions.fk_related_model_id === parentTable.id && |
|
|
|
|
|
|
|
(c.colOptions as LinkToAnotherRecordType).fk_child_column_id === |
|
|
|
|
|
|
|
childColumn.id && |
|
|
|
|
|
|
|
(c.colOptions as LinkToAnotherRecordType).fk_parent_column_id === |
|
|
|
|
|
|
|
parentColumn.id |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
).colOptions as LinkToAnotherRecordType |
|
|
|
|
|
|
|
).fk_index_name; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
foreignKeyName = relationColOpt.fk_index_name; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// todo: handle relation delete exception
|
|
|
|
// todo: handle relation delete exception
|
|
|
|
try { |
|
|
|
try { |
|
|
|
await sqlMgr.sqlOpPlus(base, 'relationDelete', { |
|
|
|
await sqlMgr.sqlOpPlus(base, 'relationDelete', { |
|
|
@ -1761,7 +1786,7 @@ const deleteHmOrBtRelation = async ( |
|
|
|
childTable: childTable.table_name, |
|
|
|
childTable: childTable.table_name, |
|
|
|
parentTable: parentTable.table_name, |
|
|
|
parentTable: parentTable.table_name, |
|
|
|
parentColumn: parentColumn.column_name, |
|
|
|
parentColumn: parentColumn.column_name, |
|
|
|
foreignKeyName: relationColOpt.fk_index_name, |
|
|
|
foreignKeyName, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e); |
|
|
|
console.log(e); |
|
|
|