I am currently running the below code to delete all versions before doing a weekly compress. But as you can see it is very primative and the hard coding of the names is becoming annoying as I am having to edit it each time a GIS User starts or leaves our buisness.
Is there a simple tool that will find/list all versions? That way I can then go ahead and delete them once a list has been created.
# Name: DeleteAllVersion.py # Description: Deletes all versions from our SDE # By Ben Van Kesteren 22/07/2014 # Import system modules import arcpy # Set local variables inWorkspace = r"Database Connections/GISADMIN@SDE_Spatial@Smithy.sde" Nathan = "Nathan" Ben = "Ben_Edit" David = "David_Armstrong" James = "James" Patrick = "Patrick" Rory = "Rory" Josh = "Josh" MrsBeer = "Mrs_Beer_Edit" #Russell = "Muddy_Edit" Patrea = "Patrea" Kerrie = "Kerrie" SteveM = "Steve_Edit" Helen = "Helen" MattJ = "Matt_Johnson" # Execute DeleteVersion arcpy.DeleteVersion_management(inWorkspace, Nathan) arcpy.DeleteVersion_management(inWorkspace, Ben) arcpy.DeleteVersion_management(inWorkspace, David) arcpy.DeleteVersion_management(inWorkspace, James) arcpy.DeleteVersion_management(inWorkspace, Patrick) arcpy.DeleteVersion_management(inWorkspace, Rory) arcpy.DeleteVersion_management(inWorkspace, Josh) arcpy.DeleteVersion_management(inWorkspace, MrsBeer) #arcpy.DeleteVersion_management(inWorkspace, Russell) arcpy.DeleteVersion_management(inWorkspace, Patrea) arcpy.DeleteVersion_management(inWorkspace, Kerrie) arcpy.DeleteVersion_management(inWorkspace, SteveM) arcpy.DeleteVersion_management(inWorkspace, Helen) arcpy.DeleteVersion_management(inWorkspace, MattJ)
Hi Ben,
Are you reconciling/posting the version before you delete it? This is a step you will want to take to make sure you are not losing any of the user's edits. You can use the Reconcile Versions tool to do this. This tool has an option to delete the version after it's posted.
ah excellent, good point. Yes all the users are informed to reconcile or post each week prior to my weekly maintenance. This is generally successful, but as people are sometimes away at last minute we try to hold off the maintenance until everyone is at work.
One thing I would like to consider, is reconcile/post on everyone's behalf. It is very unusual for someone not to want to reconcile/post each week, so to elimate this user error possibility I would like to automate it, so this is something else I am looking at setting up during this process.
I have just had a quick look at the Reconcile Versions tool, and it is exactly what I am looking for, thanks for that Jake Skinner, greatly appreciated.
Which version of ArcGIS Desktop are you using? Does ListVersions in the ArcPy Data Access (arcpy.da) not work for you? Or, do you want to only work with a subset of all versions? Or yet, do you not know how to iterate over a list?
No you are 100% correct, I have only just now re-looked at this problem I listed a couple of months ago and it has clicked (i'm slow thats for sure! haha).
I can simply list all versions, then reconcile said versions then delete. I will give this angle a go.
Thanks for your help all.
PS.
Thanks for the help.