How-to: Delete dangling files from a Telligent Community database
The other day I came across a bug when upgrading my site to Community Server The Community Server 2008 upgrade tool would throw an exception when trying to move my files into CFS. The exception was result of the upgrade tool trying to pull down post attachments where the Section or Post didn’t exist.
This might not seem like such a bad thing, but it is for two reasons:
-
You have a file that is taking up database space that isn’t accessible within Community Server.
-
Community Server appends the SectionID to file name. Since the SectionID is null an exception will be thrown when creating the file name. I created the following SQL statement that will delete all
cs_PostAttachmentswhere theSectionIDandApplicationType is NULLand the section doesn’t exist in thecs_sectionstable.DELETEcs_PostAttachmentsFROMcs_PostAttachmentsLEFT JOINcs_SectionsONcs_Sections.SectionID = cs_PostAttachments.SectionIDWHEREcs_PostAttachments.Content NOT LIKE 0x ANDcs_Sections.SectionID IS NULL ANDcs_Sections.ApplicationType IS NULL