Stash Upgrade Fails with "Table already exists" Error

Troubleshooting Installation

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

Upgrading from Stash 2.0.3 to 2.3 fails with the following exception:

2013-04-02 17:32:43,419 ERROR [localhost-startStop-1]  liquibase Change Set liquibase/r2_2/m01.xml::STASHDEV-2892-1::tbright failed.  Error: Error executing SQL CREATE TABLE `stash`.`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 stash.repository(id) ON DELETE CASCADE): Table 'sta_configured_hook_status' already exists
liquibase.exception.DatabaseException: Error executing SQL CREATE TABLE `stash`.`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 stash.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:

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.

 

 

Last modified on Mar 30, 2016

Was this helpful?

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