Automatically delete old versioned Silverstripe records from the database
An extension for Silverstripe to automatically delete old versioned DataObject records from your database when a record is published, following predefined retention policies (see configuration).
When a record is being edited (such as a Page), no changes are made until it is published, so it could have 50 draft versions while you work on the copy. When you publish the page, the module prunes the (by default) all draft copies, leaving just the 10 latest published versions (configurable).
The module adds three manual tasks to:
The tasks can be run via /dev/tasks/TruncateVersionsTask
.
composer require axllent/silverstripe-version-truncator
Configuration is optional (see Default config), however you can create a YML file (eg: app/_config/version-truncator.yml
):
MyCustomObject:
keep_versions: 5
keep_drafts: 5
To skip pruning altogether for a particular DataObject, set keep_versions: 0
for that object class.
To overwrite the global defaults, see _config/extension.yml
, eg:
SilverStripe\CMS\Model\SiteTree:
keep_versions: 20
keep_drafts: 10
On publish, the last 10 published versions are kept, and all draft copied are removed. The only exception is if the URLSegment
and/or ParentID
is has changed, in which case the module will keep a single record for each differing URLSegment to allow auto-redirection.
For all other versioned DataObjects, only the latest published version is kept, and all drafts deleted. This can be adjusted per DataObject, or globally (see above).
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem