Utilitites for Umbraco
>>
Utilitites for Umbraco >>
ClearVersions
ClearVersions
Each time a content node is saved umbraco writes a new version for this content element and his generic properties to the database. With ClearVersions it is possible to delete old versions.
Here it can be defined from which date on the versions should be deleted or how many versions should rest in the database at least. Versions from elements which are not published will be ignored. On both methods will only the versions be deleted which are older than the published version of the element.

Details
The function is as follows:
- First all rows of the table cmsContent are loaded
- For each content element all versions will be loaded from cmsContentVersion (sorted descending for the date)
- Now the version which is published is searched. Only now the next version will be proofed for deleting. This is for keeping all versions which are newer thatn the published one.
- Now each version will be checked if it matchs the criteria for deleting (older than the defined date or already x versions kept in the database).
- If it matchs all entries for this version from cmsPropertyData, cmsDocument und cmsContentVersion will be deleted.