How to replace old View File macros with the new File Preview macro
Purpose
Confluence 5.7 introduced File Previews as a new way to visualize attachments: Confluence 5.7 Release Notes. In some cases, you might want to replace the old macros in order to use the new features.
Solution
- Stop Confluence
- Run the following queries in your Confluence database. These steps were tested in PostgreSQL and might need to be adapted to work with a different database server. Each query is for a different type of file:
MS Word
UPDATE bodycontent SET body = replace(body, 'ac:name="viewdoc"', 'ac:name="view-file"') WHERE contentid IN (SELECT contentid FROM content WHERE prevver IS null AND contenttype in ('BLOGPOST', 'PAGE', 'COMMENT')) AND body LIKE '%ac:name="viewdoc"%';
MS Excel
UPDATE bodycontent SET body = replace(body, 'ac:name="viewxls"', 'ac:name="view-file"') WHERE contentid IN (SELECT contentid FROM content WHERE prevver IS null AND contenttype in ('BLOGPOST', 'PAGE', 'COMMENT')) AND body LIKE '%ac:name="viewxls"%';
MS PowerPoint
UPDATE bodycontent SET body = replace(body, 'ac:name="viewppt"', 'ac:name="view-file"') WHERE contentid IN (SELECT contentid FROM content WHERE prevver IS null AND contenttype in ('BLOGPOST', 'PAGE', 'COMMENT')) AND body LIKE '%ac:name="viewppt"%';
PDF
UPDATE bodycontent SET body = replace(body, 'ac:name="viewpdf"', 'ac:name="view-file"') WHERE contentid IN (SELECT contentid FROM content WHERE prevver IS null AND contenttype in ('BLOGPOST', 'PAGE', 'COMMENT')) AND body LIKE '%ac:name="viewpdf"%';
- Start Confluence
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.
Last modified on Feb 26, 2016
Powered by Confluence and Scroll Viewport.