Upgrading Confluence fails due to conflict with FOREIGN KEY constraint 'fk_ao_9412a1_user_app_link_user_id' error

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

Problem

Upgrading Confluence fails with an error related to a foreign key constraint

The following appears in the atlassian-confluence.log

1 2016-04-27 08:26:13,463 ERROR [localhost-startStop-1] [atlassian.confluence.plugin.PluginFrameworkContextListener] launchUpgrades Upgrade failed, application will not start: Upgrade task com.atlassian.confluence.upgrade.upgradetask.MsSqlServerAoUpgradeTask@1b240eb1 failed during the SCHEMA_UPGRADE phase due to: StatementCallback; SQL [ALTER TABLE AO_9412A1_USER_APP_LINK ADD CONSTRAINT fk_ao_9412a1_user_app_link_user_id FOREIGN KEY (USER_ID) references AO_9412A1_AOUSER(ID);]; The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "fk_ao_9412a1_user_app_link_user_id". The conflict occurred in database "WikiTEST", table "dbo.AO_9412A1_AOUSER", column 'ID'.; nested exception is java.sql.SQLException: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "fk_ao_9412a1_user_app_link_user_id". The conflict occurred in database "WikiTEST", table "dbo.AO_9412A1_AOUSER", column 'ID'

Cause

The conflict occurs because the constraint already exists in the database.

Workaround

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.

  1. Rollback Confluence to pre-upgraded state.

  2. Back up the database.

  3. Drop the foreign key constraint fk_ao_9412a1_user_app_link_user_id. The following query is for MySQL, please modify for any changes with the database being used.

    1 2 ALTER TABLE AO_9412A1_USER_APP_LINK DROP CONSTRAINT fk_ao_9412a1_user_app_link_user_id;
  4. Upgrade Confluence.

Updated on April 15, 2025

Still need help?

The Atlassian Community is here for you.