Upgrade Failed with "Table has no primary key" Error Message
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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
Symptoms
The Confluence upgrade process failed due a missing primary key or constraint in one of its tables. In the below example the problematic table is the LINKS table. The following appears in atlassian-confluence.log
2015-01-12 14:22:56,204 ERROR [localhost-startStop-1] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized Upgrade failed, application will not start: Upgrade task com.atlassian.confluence.upgrade.upgradetask.LowerCaseUsernameReferencesUpgradeTask@292e1ad3 failed during the SCHEMA_UPGRADE phase due to: Table 'LINKS' has no primary key
com.atlassian.confluence.upgrade.UpgradeException: Upgrade task com.atlassian.confluence.upgrade.upgradetask.LowerCaseUsernameReferencesUpgradeTask@292e1ad3 failed during the SCHEMA_UPGRADE phase due to: Table 'LINKS' has no primary key
at com.atlassian.confluence.upgrade.AbstractUpgradeManager.executeUpgradeStep(AbstractUpgradeManager.java:273)
at com.atlassian.confluence.upgrade.AbstractUpgradeManager.runSchemaUpgradeTasks(AbstractUpgradeManager.java:217)
at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:167)
at com.atlassian.confluence.upgrade.UpgradeLauncherServletContextListener.contextInitialized(UpgradeLauncherServletContextListener.java:51)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Cause
There are two possible causes for this behavior:
- The constraint was previously removed while making changes to the database.
- The constraint was not added during a previous upgrade attempt.
Resolution
- Restore your database from a working backup.
- Create a temporary Confluence instance that matches the version you restored to.
- Match the LINKS table from your Confluence with the LINKS table from the fresh installation.
- Shutdown your Confluence.
- Backup your database.
- Add the missing constraints so the LINKS table in both instances match
- Start Confluence.
- Try upgrading again.
- If it fails again with a different table repeat the process to find out the missing constraints and fix them (AO tables can be ignored)
Since these steps involve multiple changes to the database, we strongly recommend using a DBA to assist in this task.