How to Remove all Previous Versions of a Page Manually in the Database Using SQL Commands
プラットフォームについて: サーバーと Data Center のみ。この記事は、サーバーおよび Data Center プラットフォームのアトラシアン製品にのみ適用されます。
問題
- Due to the Bug - CONF-29166Getting 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
データベースの操作方法が不明な場合はデータベース管理者にお問い合わせください。先に進む前にデータベースの完全なバックアップを作成するようにしてください。これらの SQL コマンドはいくつかの環境でテストされ、意図するように動作することが確認されています。しかしながら、特定の状況や Confluence の新しいバージョンでは動作しない場合があります。これは、Confluence のデータベース構造に変更が行われている可能性があるためです。このため、問題が発生して巻き戻しを行う必要がある場合に備えたデータベース バックアップは必須です。
回避策
Shut Down Confluence
First, you must get the page name you would like to remove. Simply copy the page name exactly the same way it is written.
- 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
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.:
データベースの変更を行う場合は必ず事前にバックアップを取得してください。可能な場合は、まずステージング サーバーで SQL コマンドの変更、挿入、更新、または削除を行うようにします。
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;
Update this current version to become version 1
UPDATE CONTENT SET VERSION = 1 WHERE TITLE = '<page name>'
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
- 変更内容を反映するには、 Confluence を再起動します。
例:
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