Does Drupal 8 support referential integrity? Can I tell Drupal what it should do if a parent row in a content type is deleted? For example:

  • I could tell Drupal not to allow the deletion of a parent row if it has child rows
  • I could tell Drupal to delete all child rows that belong to a parent row when that parent row is deleted

By row I mean an item of a content type. For example, if the content type is Book, a row is the data about one book.

  • Welcome to Drupal Answers! I must admit I don't understand your question. What rows? – leymannx Sep 21 '18 at 8:27
  • @leymannx I think they are called "nodes" in Drupal, not sure. – user89571 Sep 21 '18 at 8:50
  • Are you sure, then please update your question accordingly. Otherwise it would be better to find that out yourself first and then come back and clarify. – leymannx Sep 21 '18 at 8:52
  • You should simply try it out yourself. What happens when you try to delete a node that's referenced by another node? Does it work? As far as I remember this isn't possible. But I might be wrong. Please just try it out yourself instead of letting us try it out for you. – leymannx Sep 21 '18 at 10:52

No, there's no such feature out of the box.

For D7, there is a module for that, but I haven't see a Drupal 8 version: https://www.drupal.org/project/erri.

We did build something like that ourself based on the entity_usage module, we alter the node delete form and display a warning that shows where the node is used.

  • 1
    A Drupal 8 module which facilitates the enforcement of entity references is drupal.org/project/erg. It is abandoned but the approach taken seems solid enough. – stevekeiretsu Sep 22 '18 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.