# 2941 - Error migrating database after upgrade

**URL:** https://www.finalbuilder.com/forums/t/2941-error-migrating-database-after-upgrade/5892
**Category:** Bugs
**Created:** [February 17, 2014, 1:43am UTC](https://www.finalbuilder.com/forums/t/2941-error-migrating-database-after-upgrade/5892 "2014-02-17T01:43:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![skermajo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@skermajo](https://www.finalbuilder.com/forums/u/skermajo)
#### Post date: [February 17, 2014, 1:43am UTC](https://www.finalbuilder.com/forums/t/2941-error-migrating-database-after-upgrade/5892/1 "2014-02-17T01:43:55Z")

</div>

Hi  
&nbsp;  
Error below after upgrading to 1.0.0.2941. Obviously, this is preventing us from building at the moment (haven’t tried to downgrade - seemed dangerous to me). We’re running on Postgres as installed by the Continua installer.  
  
Cheers  
  
Joel  
  
  
Log Name: &nbsp; &nbsp; &nbsp;Application  
Source: &nbsp; &nbsp; &nbsp; &nbsp;Continua  
Date: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;17/02/2014 9:43:15 AM  
Event ID: &nbsp; &nbsp; &nbsp;0  
Task Category: None  
Level: &nbsp; &nbsp; &nbsp; &nbsp; Error  
Keywords: &nbsp; &nbsp; &nbsp;Classic  
User: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;N/A  
Computer: &nbsp; &nbsp; &nbsp;BUILD-MASTER.AGData.local  
Description:  
Could not initialise database:  
  
System.Exception: An error occurred executing the following sql:  
ALTER TABLE core\_securityentitygroup ADD CONSTRAINT PK\_core\_securityentitygroup\_securityentityid\_groupid PRIMARY KEY (securityentityid, groupid)  
The error was ERROR: 42P16: multiple primary keys for table “core\_securityentitygroup” are not allowed  
&nbsp;—\> Npgsql.NpgsqlException: ERROR: 42P16: multiple primary keys for table “core\_securityentitygroup” are not allowed  
&nbsp; &nbsp;at Npgsql.NpgsqlState.\<processbackendresponses\_ver\_3\>d\_\_a.MoveNext()  
&nbsp; &nbsp;at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()  
&nbsp; &nbsp;at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()  
&nbsp; &nbsp;at Npgsql.ForwardsOnlyDataReader.NextResult()  
&nbsp; &nbsp;at Npgsql.ForwardsOnlyDataReader…ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError)<br>&nbsp; &nbsp;at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)<br>&nbsp; &nbsp;at Npgsql.NpgsqlCommand.ExecuteNonQuery()<br>&nbsp; &nbsp;at FluentMigrator.Runner.Processors.Postgres.PostgresProcessor.Process(String sql)<br>&nbsp; &nbsp;--- End of inner exception stack trace ---<br>&nbsp; &nbsp;at FluentMigrator.Runner.Processors.Postgres.PostgresProcessor.Process(String sql)<br>&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.AnnounceTime(String message, Action action)<br>&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.ExecuteExpressions(ICollection`1 expressions)  
&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.Up(IMigration migration)  
&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.ApplyMigrationUp(Int64 version)  
&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.MigrateUp(Boolean useAutomaticTransactionManagement)  
&nbsp; &nbsp;at FluentMigrator.Runner.Initialization.TaskExecutor.Execute()  
&nbsp; &nbsp;at Continua.Migrations.Runner.Execute(String database, String connectionString, String fileName)  
&nbsp; &nbsp;at Continua.Server.Service.Migrator.Begin()  
Exiting…  
Event Xml:  
  
&nbsp;   
&nbsp; &nbsp;   
&nbsp; &nbsp; 0  
&nbsp; &nbsp; 2  
&nbsp; &nbsp; 0  
&nbsp; &nbsp; 0x80000000000000  
&nbsp; &nbsp;   
&nbsp; &nbsp; 4158405  
&nbsp; &nbsp; Application  
&nbsp; &nbsp; BUILD-MASTER.AGData.local  
&nbsp; &nbsp;   
&nbsp;   
&nbsp;   
&nbsp; &nbsp; Could not initialise database:  
  
System.Exception: An error occurred executing the following sql:  
ALTER TABLE core\_securityentitygroup ADD CONSTRAINT PK\_core\_securityentitygroup\_securityentityid\_groupid PRIMARY KEY (securityentityid, groupid)  
The error was ERROR: 42P16: multiple primary keys for table “core\_securityentitygroup” are not allowed  
&nbsp;—&gt; Npgsql.NpgsqlException: ERROR: 42P16: multiple primary keys for table “core\_securityentitygroup” are not allowed  
&nbsp; &nbsp;at Npgsql.NpgsqlState.&lt;ProcessBackendResponses\_Ver\_3&gt;d\_\_a.MoveNext()  
&nbsp; &nbsp;at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()  
&nbsp; &nbsp;at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()  
&nbsp; &nbsp;at Npgsql.ForwardsOnlyDataReader.NextResult()  
&nbsp; &nbsp;at Npgsql.ForwardsOnlyDataReader…ctor(IEnumerable`1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean synchOnReadError)<br>&nbsp; &nbsp;at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)<br>&nbsp; &nbsp;at Npgsql.NpgsqlCommand.ExecuteNonQuery()<br>&nbsp; &nbsp;at FluentMigrator.Runner.Processors.Postgres.PostgresProcessor.Process(String sql)<br>&nbsp; &nbsp;--- End of inner exception stack trace ---<br>&nbsp; &nbsp;at FluentMigrator.Runner.Processors.Postgres.PostgresProcessor.Process(String sql)<br>&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.AnnounceTime(String message, Action action)<br>&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.ExecuteExpressions(ICollection`1 expressions)  
&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.Up(IMigration migration)  
&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.ApplyMigrationUp(Int64 version)  
&nbsp; &nbsp;at FluentMigrator.Runner.MigrationRunner.MigrateUp(Boolean useAutomaticTransactionManagement)  
&nbsp; &nbsp;at FluentMigrator.Runner.Initialization.TaskExecutor.Execute()  
&nbsp; &nbsp;at Continua.Migrations.Runner.Execute(String database, String connectionString, String fileName)  
&nbsp; &nbsp;at Continua.Server.Service.Migrator.Begin()  
Exiting…  
&nbsp;   
\</processbackendresponses\_ver\_3\>

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [February 17, 2014, 2:39am UTC](https://www.finalbuilder.com/forums/t/2941-error-migrating-database-after-upgrade/5892/2 "2014-02-17T02:39:15Z")

</div>

Hi Joel,  
  
Can you shutdown the continua server service, run the following SQL commands on your postgres database, then restart the server service?

`ALTER` `TABLE` `core_securityentitygroup ``DROP` `CONSTRAINT` `pk_core_securityentitygroup_securityentityid_groupid;`

&nbsp;

`ALTER` `TABLE` `core_accesscontrollistentryrole ``DROP` `CONSTRAINT` `pk_core_accesscontrollistentryrole_accesscontrollistentryid_rol;`

  
The latest build adds primary keys which were missing in previous builds. I’m not sure why you already had them - &nbsp;I’ll investigate

---

<div class="post-metadata">

### Author: ![skermajo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@skermajo](https://www.finalbuilder.com/forums/u/skermajo)
#### Post date: [February 17, 2014, 3:11am UTC](https://www.finalbuilder.com/forums/t/2941-error-migrating-database-after-upgrade/5892/3 "2014-02-17T03:11:55Z")

</div>

Thanks Dave.   
  
 In addition to those two I also had to drop pk\_versioninfo\_version from versioninfo. After doing that everything starts up as expected (and the keys reappeared). Thanks for helping sort it so quickly!   
  
 Joel

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [February 17, 2014, 3:20am UTC](https://www.finalbuilder.com/forums/t/2941-error-migrating-database-after-upgrade/5892/4 "2014-02-17T03:20:50Z")

</div>

Hi Joel,&nbsp;  
  
Good to know that its now working. I think your Continua server must have started as an early beta version?&nbsp;The primary keys existed in a beta version 16 months ago&nbsp;but were incorrectly commented out from the migration. We will now update the migration code to check if they exist before creating them.

---

<div class="post-metadata">

### Author: ![skermajo](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@skermajo](https://www.finalbuilder.com/forums/u/skermajo)
#### Post date: [February 17, 2014, 3:26am UTC](https://www.finalbuilder.com/forums/t/2941-error-migrating-database-after-upgrade/5892/5 "2014-02-17T03:26:40Z")

</div>

Thanks Dave. Yes, this server has been around since early betas.
