I've been working on a site for a while in beta. The number of versions for all the pages is getting big and the database is now over 2MB. I'd love to just delete all the old versions of all pages when I go live with the site. Is there any easy way to do this?
I just wrote a plugin that deletes all versions (truncates the
craft_entryversions table) and then saves a new version for each of your entries, so you can later revert back to it:
I have a site with quite a lot of traffic and user submissions. After a while DB backups started taking too long (uncompressed sql dump over 300mb).
Instead of keeping the last change, I now keep 30 days worth of changes. I have a cron job set up to remove older revisions.
mysql -e 'DELETE FROM craft_entryversions WHERE dateUpdated < DATE_SUB(NOW(),INTERVAL 30 DAY)' dbname
If you don't need revisions for certain sections, just disable revisions altogether on a per section basis.
I hope this helps other people with large
You should be able to just safely delete them from the
Obviously this deletes all your entry versions, so each entry will just exist at its last known 'live' state.
Also, backup your database first. :)
Just to add to this, you can easily remove previous versions of files (except the current/most recent) with the following SQL query:
DELETE FROM craft_entryversions WHERE id NOT IN (SELECT id FROM (SELECT max(id), entryId FROM craft_entryversions GROUP BY entryId) X);
Obviously backup the old database/table first!