How to Remove all Previous Versions of a Page Manually in the Database Using SQL Commands

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

この記事はアトラシアンのサーバー製品にのみ適用されます。クラウドとサーバー製品の違いについてはこちらをご確認ください。

問題

  • Due to the Bug  CONF-29166 - Getting issue details... STATUS  (Unable to delete blog version), Currently there is no way to delete old version of a blog page through UI.
  • You would like to bulk remove previous versions of a page

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.

回避策

  1. Shut Down Confluence

  2. First, you must get the page name you would like to remove. Simply copy the page name exactly the same way it is written.

  3. Obtain the number of the current version of the blog post. This is the version that you would like to save. This is obtainable by going to the Blog Page > Tools > Page History > Take note of the "current" version
  4. Run the following queries in the database, in order, since the database contain constraints which will prevent foreign keys and primary keys to be violated if you try to remove one which is mentioned on another table. Replace the <page name> with the actual page name you have copied before.:

    データベースの変更を行う場合は必ず事前にバックアップを取得してください。

    (info) The following SQL has not been tested in Confluence 5.7 and above

    create table TEMP_CONTENT like CONTENT;
    insert into TEMP_CONTENT SELECT * FROM content WHERE TITLE = '<page name>' AND VERSION != <current version number>;
     
    delete from links where contentid in (select tc.CONTENTID from TEMP_CONTENT tc);
    
     
    delete from imagedetails where attachmentid in(select attachmentid from attachments where pageid in (select tc.CONTENTID from TEMP_CONTENT tc));
    
     
    delete from attachments where pageid in (select tc.CONTENTID from TEMP_CONTENT tc);
    
    delete from notifications where contentid in (select tc.CONTENTID from TEMP_CONTENT tc);
    
    delete from confancestors where descendentid in (select tc.CONTENTID from TEMP_CONTENT tc);
    
    delete from bodycontent where contentid in (select tc.CONTENTID from TEMP_CONTENT tc);
    
    delete from CONTENT where CONTENTID in (select tc.CONTENTID from TEMP_CONTENT tc);
    
    drop table TEMP_CONTENT;
  5. Update this current version to become version 1

    UPDATE CONTENT SET VERSION = 1 WHERE TITLE = '<page name>'
  6. Lastly, check if the operation is complete from the following SQL query:

    SELECT * FROM CONTENT where TITLE = '<page name>'

    * This should return with one value, with version = 1

  7. Restart Confluence for the changes to take effect.

例:

For example, Below is a situation where a blog with the name "Test 584 Blog" with 5 versions, and you would like to delete all 4 versions before version 5:

Therefore, replace <page name> with Test 584 Blog and replace <current version number> with 5 in the SQL query given in "Workaround" section


 


最終更新日 2017 年 3 月 7 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.