Upgrade to Confluence Fails on Bandana_Unique_Key Relation

Still need help?

The Atlassian Community is here for you.

Ask the community


When upgrading to 4.x or above from a 3.5.x or earlier version, the upgrade fails and the following appears in the atlassian-confluence.log:

ERROR [main] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized Upgrade failed, application will not start: Upgrade task com.atlassian.confluence.upgrade.upgradetask.BandanaKeyUniqueConstraintUpgradeTask@bce3d7 failed during the SCHEMA_UPGRADE phase due to: StatementCallback; bad SQL grammar [alter table BANDANA alter column BANDANACONTEXT set not null, alter column BANDANAKEY set not null, add constraint bandana_unique_key unique (BANDANACONTEXT, BANDANAKEY)]; nested exception is org.postgresql.util.PSQLException: Error: "bandana_unique_key" relation is already existed.


This occurred in Postgres database, but might occur in other databases as well.


The problem is caused when the database attempts to insert a constraint called bandana_unique_key, which already exists in the schema.


Perform a backup of the database. Then run the following SQL command in the Confluence database before attempting the upgrade.

  1. Shutdown Confluence
  2. Run this command:

    ALTER TABLE bandana DROP CONSTRAINT bandana_unique_key;

    This will drop the constraint, but during the upgrade it will be created again.

    In MySQL, "DROP CONSTRAINT" isn't a known command, so to drop that unique key use the following:

    ALTER TABLE bandana DROP INDEX bandana_unique_key;

Last modified on Jan 21, 2022

Was this helpful?

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