Delete all items from recycle bin

by Damiaan Peeters 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

 

EDIT 2014-08-06

in umbraco v6 you need to run this script a few times (because it's out of order) and include this:

    delete umbracodomains
    --select umbracodomains.*
    from umbracoDomains inner join umbracoNode on umbracodomains.domainrootstructureid = umbraconode.id
    where umbraconode.path like '%-20%' and umbraconode.id!=-20

Tags:

Umbraco

blog comments powered by Disqus

Who.I.am

Certified Umbraco Master, Part of Umbraco Certified partner comm-it, .Net and Azure developer, seo lover. Magician in my spare time.

Month List