How to remove a flow from the database

Hi Chrstine,

In general, I would not recommend to directly interact with the database whenever possible. Is there a business reason why you want to delete the definitions? If there isn’t, just leave it. Flowable has a strong focus on versioning and consistency so having all these definitions is actually helpful.

One way you could potentially achieve your goal is by deleting the deployment which contains the definition you want to get rid off.

You can do so by using the RepositoryService:
repositoryService.deleteDeployment(yourDeploymentId, true);

You can retrieve the the deploymentId of your process definition by calling processDefinition.getDeploymentId().

The second parameter indicates whether you also want to delete the instances and historic instances. Please be aware that deleting a deployment means that the other definitions of that deployment are deleted as well.

You can also have a look at the following method to get some insights what’s happening:
org.flowable.engine.impl.persistence.deploy.DeploymentManager#removeDeployment

2 Likes