Bitbucket Server Upgrade Fails with "Table already exists" 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

Symptoms

Upgrading from Bitbucket Server 2.0.3 to 2.3 fails with the following exception:

1 2 2013-04-02 17:32:43,419 ERROR [localhost-startStop-1] liquibase Change Set liquibase/r2_2/m01.xml::BSERVDEV-2892-1::tbright failed. Error: Error executing SQL CREATE TABLE `bitbucket`.`sta_configured_hook_status` (`id` INT NOT NULL, `repo_id` INT NULL, `hookkey` VARCHAR(255) NOT NULL, `enabled` TINYINT(1) NOT NULL, CONSTRAINT `PK_STA_CONFIGURED_HOOK_STATUS` PRIMARY KEY (`id`), CONSTRAINT `fk_repository_hook_status` FOREIGN KEY (`repo_id`) REFERENCES bitbucket.repository(id) ON DELETE CASCADE): Table 'sta_configured_hook_status' already exists liquibase.exception.DatabaseException: Error executing SQL CREATE TABLE `bitbucket`.`sta_configured_hook_status` (`id` INT NOT NULL, `repo_id` INT NULL, `hookkey` VARCHAR(255) NOT NULL, `enabled` TINYINT(1) NOT NULL, CONSTRAINT `PK_STA_CONFIGURED_HOOK_STATUS` PRIMARY KEY (`id`), CONSTRAINT `fk_repository_hook_status` FOREIGN KEY (`repo_id`) REFERENCES bitbucket.repository(id) ON DELETE CASCADE): Table 'sta_configured_hook_status' already exists

Cause

The table 'sta_configured_hook_status' already exists in the DB schema at the time of the upgrade process.

This table should not be present in 2.0.3, as it was only introduced in later versions.

The database is in an inconsistent state because due to a previous failed upgrade attempt, the backup was restored on to an existing (updated/newer) database schema.

Resolution

Ensure there is no content in the following two tables:

  • sta_configured_hook_status

  • sta_repo_settings

as these are the two new tables added to the schema. Then delete them:

1 2 drop table sta_configured_hook_status; drop table sta_repo_settings;

And reattempt the upgrade.

This issue is also being tracked here. You may watch it to be informed of its progress and also feel free to comment there.

Updated on April 11, 2025

Still need help?

The Atlassian Community is here for you.