Skip to content

Instantly share code, notes, and snippets.

@clausjensen
Created October 25, 2016 13:38
Show Gist options
  • Save clausjensen/348a0a79e2d468399ade47cb76026af7 to your computer and use it in GitHub Desktop.
Save clausjensen/348a0a79e2d468399ade47cb76026af7 to your computer and use it in GitHub Desktop.
DELETE FROM umbracoUser2NodeNotify WHERE umbracoUser2NodeNotify.nodeId IN (SELECT TB1.nodeId FROM umbracoUser2NodeNotify as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM umbracoUser2NodePermission WHERE umbracoUser2NodePermission.nodeId IN (SELECT TB1.nodeId FROM umbracoUser2NodePermission as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM umbracoAccessRule WHERE umbracoAccessRule.accessId IN (
SELECT TB1.id FROM umbracoAccess as TB1
INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id
WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM umbracoAccess WHERE umbracoAccess.nodeId IN (SELECT TB1.nodeId FROM umbracoAccess as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM umbracoRedirectUrl WHERE umbracoRedirectUrl.id IN(
SELECT TB1.id FROM umbracoRedirectUrl as TB1
INNER JOIN umbracoNode as TB2 ON TB1.contentKey = TB2.uniqueId
WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM umbracoRelation WHERE umbracoRelation.parentId IN (SELECT TB1.parentId FROM umbracoRelation as TB1 INNER JOIN umbracoNode as TB2 ON TB1.parentId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM umbracoRelation WHERE umbracoRelation.childId IN (SELECT TB1.childId FROM umbracoRelation as TB1 INNER JOIN umbracoNode as TB2 ON TB1.childId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM cmsTagRelationship WHERE cmsTagRelationship.nodeId IN (SELECT TB1.nodeId FROM cmsTagRelationship as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM umbracoDomains WHERE umbracoDomains.domainRootStructureID IN (SELECT TB1.domainRootStructureID FROM umbracoDomains as TB1 INNER JOIN umbracoNode as TB2 ON TB1.domainRootStructureID = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM cmsDocument WHERE cmsDocument.nodeId IN (SELECT TB1.nodeId FROM cmsDocument as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM cmsPropertyData WHERE cmsPropertyData.contentNodeId IN (SELECT TB1.contentNodeId FROM cmsPropertyData as TB1 INNER JOIN umbracoNode as TB2 ON TB1.contentNodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM cmsPreviewXml WHERE cmsPreviewXml.nodeId IN (SELECT TB1.nodeId FROM cmsPreviewXml as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM cmsContentVersion WHERE cmsContentVersion.ContentId IN (SELECT TB1.ContentId FROM cmsContentVersion as TB1 INNER JOIN umbracoNode as TB2 ON TB1.ContentId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM cmsContentXml WHERE cmsContentXml.nodeId IN (SELECT TB1.nodeId FROM cmsContentXml as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
DELETE FROM cmsContent WHERE cmsContent.nodeId IN (SELECT TB1.nodeId FROM cmsContent as TB1 INNER JOIN umbracoNode as TB2 ON TB1.nodeId = TB2.id WHERE TB2.trashed = '1' AND TB2.nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972')
UPDATE umbracoNode SET parentID = '-20' WHERE trashed = '1' AND nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972'
ALTER TABLE umbracoNode NOCHECK CONSTRAINT FK_umbracoNode_umbracoNode_id
ALTER TABLE cmsContent NOCHECK CONSTRAINT FK_cmsContent_umbracoNode_id
ALTER TABLE cmsDocument NOCHECK CONSTRAINT FK_cmsDocument_umbracoNode_id
ALTER TABLE cmsPropertyData NOCHECK CONSTRAINT FK_cmsPropertyData_umbracoNode_id
DELETE FROM umbracoNode WHERE trashed = '1' AND nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972'
ALTER TABLE umbracoNode CHECK CONSTRAINT FK_umbracoNode_umbracoNode_id
ALTER TABLE cmsContent CHECK CONSTRAINT FK_cmsContent_umbracoNode_id
ALTER TABLE cmsDocument CHECK CONSTRAINT FK_cmsDocument_umbracoNode_id
ALTER TABLE cmsPropertyData CHECK CONSTRAINT FK_cmsPropertyData_umbracoNode_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment