How To Move Pin Comments From Attachments to Page Comments

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This article will help you generating the necessary queries to move all pin comments from your attachments to the page that the attachment is located. This helps keeping the comments in scenarios where there's a need to disable the Preview plugin.

Solution

  • Run the query below against your Confluence database to generate the update queries:

    1 2 3 4 5 SELECT DISTINCT concat('UPDATE content SET pageid=',c1.pageid,' WHERE pageid=',c2.pageid, ';') FROM content c1 INNER JOIN content c2 ON c1.contentid = c2.pageid WHERE c1.contenttype = 'ATTACHMENT' AND c2.contenttype = 'COMMENT';

    Note that depending on your database, the content table name might be in uppercase, so you'll need to update the query to match it.

  • The query above will return the queries that you need to run against your database. Here is an example of results:

    1 2 3 4 5 6 7 8 9 10 11 concat ----------------------------------------------------------- UPDATE content SET pageid=26542115 WHERE pageid=26542332; UPDATE content SET pageid=14221492 WHERE pageid=14221493; UPDATE content SET pageid=26542123 WHERE pageid=26542125; (3 rows)

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

  • After generating the queries and saving a backup copy of your database, shut down your Confluence instance.

  • While Confluence is down, please run the queries against the application's database.

  • Start Confluence again and check if the comments were migrated successfully.

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.