Skip to content

Instantly share code, notes, and snippets.

@nick-hoang
Forked from kipusoep/umbraco-clear-recycle-bin.sql
Last active September 21, 2018 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nick-hoang/8c2d4146b8dae2b89cc855480b563c0c to your computer and use it in GitHub Desktop.
Save nick-hoang/8c2d4146b8dae2b89cc855480b563c0c to your computer and use it in GitHub Desktop.
--Delete old nodes (keep recent 15 days) from Trash, Umbraco 7.7.6
--deletes in Document
--at this point all associated media files are deleted
delete from umbracoDomains where id in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
delete from cmsDocument where nodeId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
--deletes in Content
delete from cmsPropertyData where contentNodeId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
delete from cmsPreviewXml where nodeId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
delete from cmsContentVersion where ContentId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
delete from cmsContentXml where NodeId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
--deletes in CMSNode
delete from umbracoRelation where parentId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
delete from umbracoRelation where childId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
delete from cmsTask where nodeId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
delete from umbracoUser2NodeNotify where nodeId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
delete from cmsTagRelationship where nodeId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
delete from cmsContent where nodeId in (select id from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate()));
delete from umbracoNode where trashed = 1 and createDate < DATEADD(d, -15, getdate());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment