Drupal - How I can delete all node/field revisions?
There's not yet a stable release for Revision deletion but a D7 port is on its way (not sure if its functional at all).
In this thread someone suggested using VBO to isolate revisions and delete them.
If you feel comfortable with the API, make a loop through all your nodes, retrieves the revisions using node_revision_list()
and delete them using node_revision_delete()
.
As a last resort and if you like messing with the DB (like I do) you can delete revisions' rows in field_revision_*
and node_revision
tables. Try this:
WARNING: not tested at all !
DELETE FROM field_revision_body
WHERE NOT EXISTS (
SELECT NULL
FROM node
WHERE vid = revision_id
);
DELETE FROM node_revision
WHERE NOT EXISTS (
SELECT NULL
FROM node
WHERE node.vid = node_revision.vid
);
You can find the complete list of your revisions' tables in the information_schema
database:
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME LIKE 'field_revision%'
AND TABLE_SCHEMA = 'your_database';
Use the Node Revision Delete module to delete and manage your revisions. (I am the maintainer of the module.)
The Node Revision Delete module allows you to manage the revisions of the Node according to your choice. It helps you to keep the specific number of revisions for the node. This module provides you the flexibility for applying the revision delete for the specific content type and run it on the specific time. You can manage your settings from the Node Revision Delete Administration Page.
In same situation I used code below:
foreach (node_load_multiple($nids) as $node) {
// Delete sub revisions.
foreach (node_revision_list($node) as $vid => $revision) {
node_revision_delete($vid);
}
// Delete archived revisions.
revisioning_delete_archived_revisions($node);
}