Upgrade from 3.3.19 to 3.3.20 database upgrade failed

Hi,
When I upgraded to 3.3.20 (or later) from 3.3.19, during the database upgrade the service stops.

I get event log entries like:

2016-10-13 22:29:56.6728      7 FATAL  Unhandled AppDomain exception occurred: Database upgrade failed: The object with name "Project" already exists.
The object with name "Release" already exists.
The object with name "Deployment" already exists.
The object with name "Machine" already exists.
The object with name "Feed" already exists.
Database upgrade logs:
Beginning database upgrade
Fetching list of already executed scripts.
Executing SQL Server script 'Octopus.Core.UpgradeScripts.Script0000 - Fix wrong schema.sql'
SQL exception has occured in script: 'Octopus.Core.UpgradeScripts.Script0000 - Fix wrong schema.sql'

I have reverted back to 3.3.19 for now

Database: SQL Server 2014 SP2

Hi Jeremy,

Thanks for getting in touch! I’m sorry you’ve bumped into this problem. Octopus expects all of its database entities to be stored in the dbo schema, and it also expects to manage its own database. The script you’re seeing fail is attempting to ensure all of the Octopus tables etc are in the dbo schema - but looks like it’s failing because these tables exist in both a custom schema and the dbo schema already.

I’m not sure how the database would have made it into this state… but could you check if I’m right?

Note: Please take a backup of your database before starting this fix. I would also recommend putting your Octopus server in Maintenance Mode which will stop new deployments from starting - just in case you need to restore your database backup.

If I am correct in my assumption, the way to fix this is:

  1. Look at each duplicate table, and figure out which table is empty
  2. Delete that table from the database.
  3. After you have removed the duplicates, try upgrading again.

Please get back in touch if you have any more problems with this upgrade. :slight_smile:

Hope that helps!
Mike