<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><a href="https://dev.mysql.com/doc/refman/8.4/en/optimizing-myisam.html">MyISAM</a> compatibility was an earlier reason why FK constraints were not applied.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Now that InnoDB is default and preferred we could enforce it.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">For migration we have to clear the orphan records and then enable constraints.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">For reference field relation ON DELETE SET NULL might be required.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Added notes to issue.</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Jul 4, 2025 at 6:20 PM Alan Lord <<a href="mailto:alanslists@gmail.com">alanslists@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Done: <a href="https://code.vtiger.com/vtiger/vtigercrm/-/issues/1983" rel="noreferrer" target="_blank">https://code.vtiger.com/vtiger/vtigercrm/-/issues/1983</a><br>
<br>
Al<br>
<br>
On 04/07/2025 11:52, Prasad wrote:<br>
> Please add an issue on the tracker <br>
> <<a href="https://code.vtiger.com/vtiger/vtigercrm/-/issues" rel="noreferrer" target="_blank">https://code.vtiger.com/vtiger/vtigercrm/-/issues</a>>.<br>
> <br>
> On Fri, Jul 4, 2025 at 2:38 PM Alan Lord <br>
> <<a href="mailto:alanslists@gmail.com" target="_blank">alanslists@gmail.com</a> <br>
> <mailto:<a href="mailto:alanslists@gmail.com" target="_blank">alanslists@gmail.com</a>>> wrote:<br>
> <br>
> A customer just asked me about this...<br>
> <br>
> When they remove some records from the Recycle bin for a custom module,<br>
> the entry in crmentity is removed, but the rows in the module's own<br>
> tables are not deleted.<br>
> <br>
> Looking at the Module Model for the Recycle Bin I can see why:<br>
> <br>
> <a href="https://code.vtiger.com/vtiger/vtigercrm/-/blob/master/pkg/vtiger/modules/RecycleBin/modules/RecycleBin/models/Module.php#L147" rel="noreferrer" target="_blank">https://code.vtiger.com/vtiger/vtigercrm/-/blob/master/pkg/vtiger/modules/RecycleBin/modules/RecycleBin/models/Module.php#L147</a> <<a href="https://code.vtiger.com/vtiger/vtigercrm/-/blob/master/pkg/vtiger/modules/RecycleBin/modules/RecycleBin/models/Module.php#L147" rel="noreferrer" target="_blank">https://code.vtiger.com/vtiger/vtigercrm/-/blob/master/pkg/vtiger/modules/RecycleBin/modules/RecycleBin/models/Module.php#L147</a>><br>
> <br>
> So my question is really about foreign key constraints.<br>
> <br>
> When we create a new module, should the vtlib code be adding a foreign<br>
> key constraint and a on delete cascade?<br>
> <br>
> <a href="https://code.vtiger.com/vtiger/vtigercrm/-/blob/master/vtlib/Vtiger/ModuleBasic.php?ref_type=heads#L294" rel="noreferrer" target="_blank">https://code.vtiger.com/vtiger/vtigercrm/-/blob/master/vtlib/Vtiger/ModuleBasic.php?ref_type=heads#L294</a> <<a href="https://code.vtiger.com/vtiger/vtigercrm/-/blob/master/vtlib/Vtiger/ModuleBasic.php?ref_type=heads#L294" rel="noreferrer" target="_blank">https://code.vtiger.com/vtiger/vtigercrm/-/blob/master/vtlib/Vtiger/ModuleBasic.php?ref_type=heads#L294</a>><br>
> <br>
> Thanks<br>
> <br>
> Al<br>
> <br>
> _______________________________________________<br>
> <a href="http://www.vtiger.com/" rel="noreferrer" target="_blank">http://www.vtiger.com/</a> <<a href="http://www.vtiger.com/" rel="noreferrer" target="_blank">http://www.vtiger.com/</a>><br>
> <br>
> <br>
> _______________________________________________<br>
> <a href="http://www.vtiger.com/" rel="noreferrer" target="_blank">http://www.vtiger.com/</a><br>
<br>
<br>
_______________________________________________<br>
<a href="http://www.vtiger.com/" rel="noreferrer" target="_blank">http://www.vtiger.com/</a></blockquote></div>