/ Development  

Deleting an entity the proper way

Hi there AppWorks fans,

Welcome to a new installment of AppWorks tips.

This post will give an inside on what will happen when you delete an entity in design-time when it is also already used in the runtime environment…Smart to do?…It depends!


Let get right into it…

But an upfront note…Don’t try this at home as data will be deleted from the solution!!

This demonstration shows you what you will face when you delete an entity from the solution. This way you know what to expect when you are required to delete an entity in production!

For the post we use the already created ‘Test’ entity we used for the previous post. This entity was nothing special, but with the ‘Create’ form we were able to create new instances and the ‘AllTests’ list made them searchable in the front-end.

Nothing fancy so far but be sure you have it available with this described scenario.

delete_001

And an image from the design-time

delete_002

Ok?…ready?…Drop it!

delete_003

Are we sure?…Sure!!

delete_004

Let’s validate and publish the project.

Now <Ctrl> + <F5> on the front-end to refresh the page…It’s still there…Lucky us!

Back to the design-time for a ‘Clean built’

delete_005

And validate with a publish…Check on the front-end?…Still there!…Unbreakable, but also good for us when we were on production!

Ok…Go to the ‘/app/admin’ part of the solution.

delete_006

It’s still there and should also be proper deleted here, but wait…

First, we’ll create a new entity with…Indeed that same name ‘Test’ in the design-time!

Something should happen as the database table is still available SELECT * FROM o2appworkstipsappworkstest;

So, the save of a new one

delete_007

Would be fine….Now for a publish!

And there you have it…As expected…a ‘DuplicateNameException’…And even the ‘Extended’ variant.

delete_008

Just cancel the new created ‘Test’ and get back to the ‘deleted’ state without the ‘Test’ entity in design-time.

Ready for the delete action from the ‘/app/admin’ part of the solution?

delete_009

And are we sure?…sure!

delete_010

This triggers the real ‘kill’ of the entity (incl. the created instances!!)…A refresh of the front-end really removed the ‘AllTests’ list and even on database level we get an error on our query

delete_011

After this deletion we can properly save, validate and publish our new ‘Test’ entity from the design-time.


This last logical error brings us a ‘DONE’ to this post where we learned about deleting an entity. Not hard to do, but now you know what to expect. Have a good one…Cheers!

Don’t forget to subscribe to get updates on the activities happening on this site.