How to mark several Business Processes as deleted via database
You can mark several Business Processes (BP) as deleted. During the operation, the processes are not removed physically from a database, only the status flag is changed.
Do not forget to back up the database before the operation.
To bulk mark BPs, follow the steps below:
Analyze the number of process instances per BP:
SELECT c.title, count(*) rCount FROM Run r JOIN `CampaignMap` cm ON r.`campaignMap_id` = cm.id JOIN `Campaign` c ON cm.parent = c.id WHERE c.`type`='COMPOSITE' AND r.`status`='COMPLETED' AND r.uuid = r.`rootRunUUID` GROUP BY r.`campaignMap_id` HAVING rCount>0 ORDER BY rCount DESC;Choose the time interval.
Run the following query to see the amount of BP instances older than the chosen time interval. Replace
20 WEEKwith the desired value of the time interval.SELECT c.title, count(*) rCount FROM Run r JOIN `CampaignMap` cm ON r.`campaignMap_id` = cm.id JOIN `Campaign` c ON cm.parent = c.id WHERE c.`type`='COMPOSITE' AND r.`status`='COMPLETED' AND r.uuid = r.`rootRunUUID` AND r.endDate <= (NOW() - INTERVAL 20 WEEK) GROUP BY r.`campaignMap_id` HAVING rCount>0 ORDER BY rCount DESC;Mark BP instances as deleted in the database. Replace
20 WEEKwith the desired value of the time interval.UPDATE Run r JOIN `CampaignMap` cm ON r.`campaignMap_id` = cm.id JOIN `Campaign` c ON cm.parent = c.id SET r.status='DELETED' WHERE c.`type`='COMPOSITE' AND r.`status`='COMPLETED' AND r.endDate <= (NOW() - INTERVAL 20 WEEK);