I have the following use case:

  1. I have a custom module, which defines a custom entity type.
  2. The custom entity type has some content in the database.
  3. Module needs to be uninstalled now, but it can't, since "There is content for the entity type" (which is true, there is content)
  4. How to extend the uninstall process of the module to first remove all the content instances and then do the rest?

I tried hook_uninstall, but that didn't help. Any ideas? Content can't be uninstalled by hand! (bigger project issue)


A potential duplicate.

The short answer (as I can see), you CAN'T right now remove content by the time you uninstalling the module. That makes you (us) to do it in two steps:

  1. Write a update_hook where you remove all the content of the custom entity
  2. You uninstall the module. (drush cex, which removes the module from
  • Indeed a duplicate of that, but since then, drupal.org/node/2688945 came a long way and is almost finished, which will make this possible. – Berdir Jul 21 '16 at 17:45

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.