Upgrading Confluence fails due to conflict with FOREIGN KEY constraint 'fk_ao_9412a1_user_app_link_user_id' error
Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.
Upgrading Confluence fails with an error related to a foreign key constraint
The following appears in the
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.
Alwaysyour data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
- Rollback Confluence to pre-upgraded state.
- Back up the database.
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;
- Upgrade Confluence.