If I need to delete a CiviCase Type or a CiviCase it can be confusing given that 'deleted' Cases are not actually removed from the db.
1 Answer
Civi Case Types cannot be deleted while there are Cases of that Type. Cases can be changed to a different Case Type which can then permit you to delete a Case Type with no Cases. But if you just want the Civi Cases gone then note that Civi Cases themselves, when 'deleted', remain in the system for audit purposes. To delete a Civi Case entirely it is necessary to do so either via the API Explorer (at /civicrm/api/explorer) or via sql.
Via API Explorer use CRM.api('case', 'delete', {'id' : xxx});
Via MySQL use
DELETE c, ca, a FROM
civicrm_case c LEFT JOIN
civicrm_case_activity ca ON c.id = ca.case_id
LEFT JOIN civicrm_activity a ON ca.activity_id = c.id
WHERE case_id = xxx;
plus need to deal with case_contacts and rows in civicrm_relationships that have case_id