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

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.

Problem

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

The following appears in the atlassian-confluence.log

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'

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

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.

  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.

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

 

Last modified on May 11, 2016

Was this helpful?

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