On delete setting/strong relations for relation settings

Ability to set behaviour of what happens to related entities when sourse is deleted.

Either:

  1. Prevent deletion (current default behaviour for when the related entity is related with required field)
  2. Cascade deletion (can set with automation, but not possible right now when it is related entity is required relation, as the initial deletion is prevented. Ideally when this setting is on, it also automatically restores, like is done for comments)
  3. Unlink. (Current default behaviour for non-required relations)

While each is now possible different required fields and automation combo, the ones that are missing are:

  1. Cascade deletion (and restoration ideally) for required fields.
  2. Prevent deletion for non-required fields.
  3. Restore cascaded deletion which was done by automation.

Using the automation to make the cascaded deletion is also risky because if the relation is not required, and is unlinked for any other reason, it will trigger the cild entity to delete, where that is not the desired behaviour. For example a self relation that changed to be top level from nested.

Thanks!

Facing issues here again. Especially for something like a “Helper Database”. I have Projects and roles, then I have a helper database thats “Project Roles”. A related project is a required field for that, but setting it to required means that I can no longer delete projects. I think I’ll just need to turn off the required limitation and cascade delete with automations. I can’t make it impossible to delete projects…

What breaks me is that the “Undo” will then bring back the entitity and not the cascaded items…

I’ll add one more functionality related to this. If relationship are set to “strong” or something (like comments are to entities), they will delete together, restore together, but ALSO duplicate together. (Deep copy)

Right now even comments don’t work in this way, but it would be nice to see to see that functionality there too I think.

Just checking I understand what this would mean - is it that you would want to have a setting that says “Entities (of type A) cannot be deleted if they have anything linked (via this relation field to type B)”.
So it’s basically the same as the current behaviour for required fields, except that entities of type B are not required to have a linked entity of type A.
Right?

Exactly!

More details here: PostgreSQL: Documentation: 17: 5.5. Constraints

Just cmd+f “on delete”, it’s a bit lower on the page. It outlines all the options and explains better than I ever could.