Delete history for active instances

Hi,

In my flowable BPMN process, there is a timer which executes every 1 minute and tries to pull the status from external service and if there is no change in the status, then timer will execute again after 1 minute. Many instances are staying active for long time and due to this old active Instances has too many records in the act_hi_actinst table. Now we realized that its a design issue and fixed to execute timers once in an hour. There is no issue with all new instances created.

Now we would like to delete the history from act_hi_actinst for the old active instances and migrate to new version(Model after fixing the above issue), so that those instances will also execute based on new timer logic.

Kindly help me how to delete the history data without effecting the process execution and should be able to migrate to new version.

Below is the code I am using to migrate process instance

ProcessDefinition processDefinition = this.processEngine.getRepositoryService().createProcessDefinitionQuery()
.processDefinitionKey(businessKey).active().latestVersion().singleResult();
ProcessInstanceMigrationDocumentImpl migrationDocument = new ProcessInstanceMigrationDocumentImpl();
migrationDocument.setActivityMigrationMappings(new ArrayList());
migrationDocument.setMigrateToProcessDefinition(processDefinition.getKey(), processDefinition.getVersion());

this.processEngine.getProcessMigrationService().migrateProcessInstance(processInstanceId, migrationDocument);

You will need to add mappings from the old activity id to the new one in the setActivityMigrationMappings method. Do try this first on a backup of your database data.

OK. I will try that. But how to safely delete data from historic activity instances table