Deleting a tenant and its data

Deleting a tenant and its data

In a multi-tenant application, the Tenant-entity has DeleteTenant action. The action seems to delete the tenant from ossys_tenant table, but the tenant's entity data is left in the entity tables. Is there a way to delete also the tenant data automatically from all entity tables? I could write an action that would run a delete statement for all entity tables, but that is not very maintainable solution.

The use case is in automatic testing. We would like to create a test tenant, populate with some data, run tests and delete the tenant and its data.

Hi Teemu,

I'm not aware of any option to automatically delete the data from all the entities. You have to write an action to perform the data deletion.

I understand your pain but I can see two points to consider that act against implementing such feature:
-You may have references for the data you want to delete, meaning that this data would also be deleted. This could lead to potencial data loss;
-You may want to convert your multi-tenant entity/application to single tenant. Since the data is still in the entities you'll have access to it. 

Kind regards,
Ivo Gonçalves
I haven't tried this but could you perhaps creat a relationship between your "Tenant" table and the rest of your data and have a delete cascade rule on the relationship(s) so that deleting the tenant would effectively delete all its data?
Yes, I see there are some issues to make automatic deletion problematic. I guess I have to write an action to delete the data. Thanks for the answers!