I have a plain list (not a document library) in SharePoint 2007 that has a lot of list item versions. I'd like to loop through the list items and programmatically delete the old versions. I am doing this with the following psuedo code:
theList = web.Lists["TheList"]
items = theList.Items
for item in items:
versions = item.Versions
versions.DeleteAll()
The call to DeleteAll() takes quite a bit of time espacially for the items with a lot of versions so it makes me think it doing its job. But with that said, after running the code the AllDocVersion table in the content database has neither decreased in size nor has it fewer items in it. More concerning is that when I programmatically inspect the versions of list items in the list, they show that they have no versions for me to delete. This makes me think there is now a bunch of orphaned items in the content database although the stsadm -o databaserepair command doesn't show any orphans.
With that said, what is the proper course of action to get this corrected?