Skip to content

Instantly share code, notes, and snippets.

@skrosoft
Last active October 20, 2018 16:45
Show Gist options
  • Save skrosoft/6a269a8a9e0a2d88aa11dae8f03c93da to your computer and use it in GitHub Desktop.
Save skrosoft/6a269a8a9e0a2d88aa11dae8f03c93da to your computer and use it in GitHub Desktop.
Allow you to clean the eZ Publish database of users - Fully remove users with no node
-----------------
-- please first activate or remove non activated users from the administration interface /user/unactivated
-----------------
-- ezcontentobject_attribute
DELETE FROM `ezcontentobject_attribute` WHERE `contentobject_id` IN (SELECT `contentobject_id` FROM `ezuser` WHERE `contentobject_id` NOT IN (SELECT `contentobject_id` FROM `ezcontentobject_tree`));
-- ezcontentobject
DELETE FROM `ezcontentobject` WHERE `id` IN (SELECT `contentobject_id` FROM `ezuser` WHERE `contentobject_id` NOT IN (SELECT `contentobject_id` FROM `ezcontentobject_tree`));
-- ezcontentobject_name
DELETE FROM `ezcontentobject_name` WHERE `contentobject_id` IN (SELECT `contentobject_id` FROM `ezuser` WHERE `contentobject_id` NOT IN (SELECT `contentobject_id` FROM `ezcontentobject_tree`));
-- ezcontentobject_version
DELETE FROM `ezcontentobject_version` WHERE `contentobject_id` IN (SELECT `contentobject_id` FROM `ezuser` WHERE `contentobject_id` NOT IN (SELECT `contentobject_id` FROM `ezcontentobject_tree`));
-- ezcobj_state_link
DELETE FROM `ezcobj_state_link` WHERE `contentobject_id` IN (SELECT `contentobject_id` FROM `ezuser` WHERE `contentobject_id` NOT IN (SELECT `contentobject_id` FROM `ezcontentobject_tree`));
-- eznode_assignment
DELETE FROM `eznode_assignment` WHERE `contentobject_id` IN (SELECT `contentobject_id` FROM `ezuser` WHERE `contentobject_id` NOT IN (SELECT `contentobject_id` FROM `ezcontentobject_tree`));
-- ezuser_setting
DELETE FROM `ezuser_setting` WHERE `user_id` IN (SELECT `contentobject_id` FROM `ezuser` WHERE `contentobject_id` NOT IN (SELECT `contentobject_id` FROM `ezcontentobject_tree`));
-- ezsearch_object_word_link
DELETE FROM `ezsearch_object_word_link` WHERE `contentobject_id` IN (SELECT `contentobject_id` FROM `ezuser` WHERE `contentobject_id` NOT IN (SELECT `contentobject_id` FROM `ezcontentobject_tree`));
-- ezuser
DELETE FROM `ezuser` WHERE `contentobject_id` NOT IN (SELECT `contentobject_id` FROM `ezcontentobject_tree`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment