-
-
Save leekelleher/1171298 to your computer and use it in GitHub Desktop.
-- Uncomment below to verify the number of nodes returned is the same as the number of nodes that is in the Recycle Bin | |
-- SELECT * FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20 | |
-- Delete all 'related' nodes and table contents... | |
DELETE FROM cmsPreviewXml WHERE nodeId IN (SELECT id FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20) | |
DELETE FROM cmsContentVersion WHERE contentId IN (SELECT id FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20) | |
DELETE FROM cmsDocument WHERE nodeId IN (SELECT id FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20) | |
DELETE FROM cmsContentXML WHERE nodeId IN (SELECT id FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20) | |
DELETE FROM cmsContent WHERE nodeId IN (SELECT id FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20) | |
DELETE FROM cmsPropertyData WHERE contentNodeId IN (SELECT id FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20) | |
DELETE FROM umbracoUser2NodePermission WHERE nodeId IN (SELECT id FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20) | |
-- delete the XML nodes... | |
DELETE FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20 |
Hi Lee. Found this script today. Do you think it's still valid? I ran it in my dev environment, and added these two lines because of a conflict I got when deleting from umbracoNode:
DELETE FROM UMBRACORELATION WHERE parentid in (select id from umbracoNode WHERE path LIKE '%-20%' AND id != -20)
DELETE FROM UMBRACORELATION WHERE childid in (select id from umbracoNode WHERE path LIKE '%-20%' AND id != -20)
The site seems to run fine after the script...
I also had to add the following two statements to make it work:
DELETE FROM cmsTagRelationship WHERE nodeId IN (SELECT id FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20)
DELETE FROM umbracoUser2NodeNotify WHERE nodeId IN (SELECT id FROM umbracoNode WHERE path LIKE '%-20%' AND id != -20)
(note that this was for a v6.2.4 site)
Originally based on a code snippet from a blog post by Lee Messenger.