How to remove the full history of a page using SQL

Still need help?

The Atlassian Community is here for you.

Ask the community

In some cases, you may want to delete the whole history of a page. There is currently a feature request ( CONF-27701 - Getting issue details... STATUS ) for more options when administering a page's history. Please feel free to add you feedback and vote for it if you are interested in this functionality

Resolution

If you are unsure how to deal with the database, contact your DBA. Make sure to have the database backed up completely before going further. These SQL commands were tested in some environments and they worked as intended, however it might not work in specific cases and newer versions of confluence as new constraints as changes may be done to confluence database structure. As such, a database backup is mandatory in case something goes wrong and you need to revert.

Please note this queries will only work when:

  • The title of the page has not changed across versions.
  • There is no other page with the same title in your Confluence instance.

The process to remove a page's history is

Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

  1. Shutdown Confluence.
  2. Backup your database in case you need to restore the data.
  3. Run the following SQL queries on your Confluence database:

    DELETE FROM extrnlnks WHERE contentid in (SELECT contentid FROM content WHERE title = 'Page Title' AND prevver IS NOT NULL);
    DELETE FROM bodycontent WHERE contentid in (SELECT contentid FROM content WHERE title = 'Page Title' AND prevver IS NOT NULL);
    DELETE FROM contentproperties where contentid in (SELECT contentid FROM content WHERE title = 'Remove my History' AND prevver IS NOT NULL);
    DELETE FROM usercontent_relation where targetcontentid in (SELECT contentid FROM content WHERE title = 'Remove my History' AND prevver IS NOT NULL);
    DELETE FROM content WHERE title = 'Page Title' AND prevver IS NOT NULL;
    UPDATE content SET version = 1 WHERE title = 'Page Title';
  4. Start Confluence.

  5. Rebuild the search index.
  6. Go to Confluence Admin > Cache Statistics and click on Flush all at the bottom of the page.

Last modified on Nov 8, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.