Project

General

Profile

Bug #446

Updated by Alexander Watzinger over 8 years ago

If e.g. a Person with relations is deleted, the relations are deleted but the relation dates remain. 

 I'm trying to avoid to "manualy" delete them because there will be many cases like that and it's just too error prone. 

 Another aproach would be to write a cleanup function which searches for orphaned entries (e.g. dates, alternative names, ...) and call it with every delete. 

 *Update* 

 Deleting dates (from entities), alternative names, and location/gis data already implemented. 

 Did a check on existing data and dates of property links seem to be the only orphaned ones. 
 No link dates, aliases or gis entries were orphaned. 

 SQL to check for orphaned data (doesn't detect dates of property links because they still have a type) 
 <pre> 
 SELECT e.id FROM crm.entity e 
 LEFT JOIN crm.link l1 on e.id = l1.domain_id 
 LEFT JOIN crm.link l2 on e.id = l2.range_id 
 LEFT JOIN crm.link_property lp1 on e.id = lp1.domain_id 
 LEFT JOIN crm.link_property lp2 on e.id = lp2.range_id 
 WHERE                 
     l1.domain_id IS NULL AND 
     l2.range_id IS NULL AND 
     lp1.domain_id IS NULL AND 
     lp2.range_id IS NULL 
 </pre>

Back