Error: The ALTER TABLE statement conflicted with the CHECK constraint CK_STAFFDATERANGE_ISUNIQUE" - when running revisions after upgrading to version 3.0"

When upgrading from version 2.9 to 3.0, and running the Service Revisions task, users may receive the error:

Running revision number 1120 for the Blackbaud.AppFx.Platform.ServiceRevisions assembly.
 Current revision #1120 <> highest revision # (1341), loadspec validation will be skipped for these revisions.
Running revision number 1120 for the Blackbaud.AppFx.Galileo.ServiceRevisions assembly.
Running revision ... RevisionID: 510 (1 of 12289) for revision set 1120
The "RunServiceRevisions" task failed unexpectedly.
Blackbaud.AppFx.Platform.BuildTasks.RunServiceRevisionsHelpers.RevisionExecutionException: An error occurred while executing a service revision.
Revision text:
                IF NOT EXISTS (SELECT * FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_STAFFDATERANGE_ISUNIQUE]') AND parent_object_id = OBJECT_ID(N'[dbo].[STAFFDATERANGE]'))
                ALTER TABLE [dbo].[STAFFDATERANGE]  WITH CHECK ADD  CONSTRAINT [CK_STAFFDATERANGE_ISUNIQUE] CHECK  (([dbo].[UFN_STAFFDATERANGE_ISUNIQUE]([CONSTITUENTID],[DATEFROM],[DATETO])=(1)))
             ---> System.Data.SqlClient.SqlException: The ALTER TABLE statement conflicted with the CHECK constraint "CK_STAFFDATERANGE_ISUNIQUE". The conflict occurred in database "Ox29Mar13Rev", table "dbo.STAFFDATERANGE".
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Blackbaud.AppFx.Platform.BuildTasks.RunServiceRevisionsHelpers.RevisionRunner.RunSQLRevision(String sql, Boolean useATransaction)
   at Blackbaud.AppFx.Platform.BuildTasks.RunServiceRevisionsHelpers.RevisionRunner.RunRevs(DBRevisions revs, Int32 startAtRevisionID, Boolean onlyLoadNonDesignerSpecs)
   --- End of inner exception stack trace ---
   at Blackbaud.AppFx.Platform.BuildTasks.RunServiceRevisionsHelpers.RevisionRunner.RunRevs(DBRevisions revs, Int32 startAtRevisionID, Boolean onlyLoadNonDesignerSpecs)
   at Blackbaud.AppFx.Platform.BuildTasks.RunServiceRevisionsHelpers.RevisionRunner.RunLatestRevisions()
   at Blackbaud.AppFx.Platform.BuildTasks.RunServiceRevisions.Execute()
   at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
Target "RunServiceRevisions" failed.

 

We are currently evaluating this issue and will update this article when we have more information.

Environment

 3.0.156

Was this article helpful?