Delete all items from recycle bin

by Damiaan 19. September 2011 22:05

Based on http://our.umbraco.org/forum/developers/api-questions/3550-Delete-items-in-Recycle-Bin but also removes the previewXML, ContentVersions and Relations.

-- 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
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 all 'related' nodes and table contents...
delete from cmsContent 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 cmsDocument 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 umbracoRelation  where parentId in (select id from umbracoNode where path like '%-20%' and id!=-20) or
childId 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

Tags:

Umbraco

blog comments powered by Disqus