Permanently deleting files from TFS Source Code Control
Not for the fainthearted this so continue with absolute caution – usual disclaimers apply most least don’t blame me if you loose your entire TFS implementation, TFS Server and most of the rest of your development universe…
So, you’re deleted a project from TFS using the TFSDeleteProject CLI command but still have crud left hanging around, taking up space or worse – still showing up if you recreate a project with the same name. The TFSDeleteProject command by nature will not delete much of anything – it simply marks a project as unused and moves it from TfsIntegration.dbo.tbl_projects to TfsIntegration.dbo.projects_tombstone (among other actions). As a result you’re still left with a potentially large DB filled with useless crud.
Files in TFS SCC are located in three tables in the tfsVersionControl database: dbo.tbl_NameSpace, dbo.tbl_File and dbo.tbl_Content.
The root table is tbl_NameSpace – this table provides the full path to the object along with an ItemId. This ItemId is used to key into the tbl_Files table which yields a FileId that joins up with tbl_Content.
You’ll want to carefully identify which items from tbl_Namespace you want to wipe out and removes the corresponding entries from the other two tables.
Backup your database first and make sure you’ve a sacrificial chicken on hand just in case…And did I happen to mention you should back up your database first…?
I’m sure there are some other tables out there affected by this but these appear to be the main three.