How to remove custom CSS from Confluence via the database

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

Purpose

If custom CSS has been added to Confluence and has broken page rendering, there is a chance it will need to be removed from the database instead of through the Confluence UI.

Solution

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.

Steps to remove custom CSS from a particular space

  1. Stop Confluence

  2. Confirm the space has CSS you need to remove via the following query (replace <spacekey> with the spacekey from the affected space):

    select * from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='<spacekey>';
  3. Run the following query to delete any custom CSS associated with that space

    delete from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='<spacekey>';
  4. Start Confluence

Steps to remove custom CSS from all spaces

  1. Stop Confluence
  2. Confirm that custom CSS stylesheets exist in any space with the following query:

    select * from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT!='_GLOBAL';
  3. Run the following query to delete all custom CSS stylesheets for any space:

    delete from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT!='_GLOBAL';
  4. Start Confluence

Steps to remove CSS from the Global Stylesheet

  1. Stop Confluence
  2. Confirm there is a custom Global Stylesheet via the following query:

    select * from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='_GLOBAL';
  3. Run the following query to delete any custom Global Stylesheets:

    delete from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='_GLOBAL';
  4. Start Confluence

Steps to remove all custom CSS Stylesheets

  1. Stop Confluence
  2. Run the following to delete any custom stylesheets:

    delete from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%';
  3. Start Confluence


NOTE

When you modify a Custom CSS for a Space from UI and remove it completely (delete it) , its entry will be stored with <null> value in Database. The reason this value is still kept in DB is because when you modify a Custom CSS from UI and then remove it completely, you are technically editing it and not deleting it. Also, the button on UI says Edit and not Delete.

So if you want to pull the list of all Spaces which currently have Custom CSS and was deleted in past, you can run the below query to fetch those Spaces.

select * from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='<spacekey>' AND BANDANAVALUE !='<null/>'



Last modified on Feb 5, 2021

Was this helpful?

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