views:

410

answers:

2

I have found that deactivating a feature in Sharepoint leaves erroneous entries in the AllDocs table in the content database. These table records then make deploying other features that contain the same filenames impossible as Sharepoint complains that they already exist. How can I make sure deactivating features does not leave old references in the content database?

Microsoft explicitly says that we should not execute queries directly on the database otherwise it will become unsupported.

all the best

+1  A: 

I recall getting that error when I attempted to redeploy a feature that was not actually deleted. Perhaps you just need to go a few steps further?

stsadm -o deactivatefeature -name YourSolutionName -url  http://yoururl
stsadm -o retractsolution -name yoursolution.wsp -immediate
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name yoursolution.wsp -override
stsadm -o execadmsvcjobs

EDIT: I'd also like to add my agreement that you should never attempt to modify the database directly.

Mayo
@mayo - I think in the above YourSolutionName would be the feature name? Does doing this via stsadm do anything extra over using the UI to do it?
78lro
I meant feature name - the solution is really a package for the feature and I don't think it has a name beyond the file name - my mistake. I generally use stsadm because it behaves more consistently than the GUI (which would time out on me on some operations, etc.).
Mayo
@mayo - seems when I deactivate the features and delete the .wsp, this row is still in this table. Is there a way I can identify the feature that needs deactivating? There is a column for setuppath as 'Features\MinimalPublishingLayouts\PageLayouts\mypage.aspx' but this has been deactivated.
78lro
I've got multiple web apps on my farm and it might also be the case that I got the error by not explicitly deactivating the feature on all of the web apps (that is - before I learned to do so). I've seen the features enumerated but I haven't done it myself - not sure how difficult that is to do (might require a script).
Mayo
A: 

Unless something goes wrong when you deactivate a feature (i.e. Unhandled exception in your FeatureDeactivated event or something similar) the features that you uninstall should not leave a trace.

I you end up with features that are still hanging on your site, I suggest using SharePoint Manager. You will be able to see everything that's installed on your Web App / Site Collection and delete the features that you don't want. All of that is done via the SharePoint object model, which means that you're never deleting anything directly from the database, and the tool works very well.

Hugo Migneron
So even for files in the master page library it should leave no entries in the AllDocs table? Maybe then this could have been a previous deployment of the feature that has failed to deactivate correctly.
78lro
@ Hugo - I will take a look the the sharepoint manager, I have used it before but not for this purpose. thx
78lro
I did spend some time looking at the ignoreifalreadyexists property on the file element as I thought this might be the culprit - http://www.sharepointvoodoomagic.com/2009/01/ignoreifalreadyexists.html
78lro