Error when applying patches on an Archive database (V2012)
Symptoms
Error when applying patches 16.01.132.000 or 16.00.543.000 on an Archive database.
Error/warning messages
Importing Changepoint SQL code failed.
Reason:
'FK_DataSourceJoin_DataSource' is not a constraint.
Could not drop constraint. See Previous errors.
Reason
Foreign keys that are being dropped and recreated by the patch, do not exist in the archive database.
Resolution
1- Execute the statements below on the Archive database only, in order to create the missing foreign keys:
ALTER TABLE [dbo].[DataSourceJoin] ADD CONSTRAINT [FK_DataSourceJoin_DataSource] FOREIGN KEY ([DataSourceId]) REFERENCES [dbo].[DataSource] ([DataSourceId])
ALTER TABLE [dbo].[DataSourceColumnJoin] ADD CONSTRAINT [FK_DataSourceColumnJoin_DataSourceColumnSourceCode] FOREIGN KEY ([DataSourceId], [ColumnId], [UnionIndex]) REFERENCES [dbo].[DataSourceColumnSourceCode] ([DataSourceId], [ColumnId], [UnionIndex])
ALTER TABLE [dbo].[DataSourceColumnJoin] ADD CONSTRAINT [FK_DataSourceColumnJoin_DataSourceJoin] FOREIGN KEY ([DataSourceJoinId]) REFERENCES [dbo].[DataSourceJoin] ([DataSourceJoinId])
2- Apply the patch to Archive database again
3- Execute the statements below on the Archive database only in order to drop the foreign keys:
ALTER TABLE [dbo].[DataSourceJoin] DROP CONSTRAINT [FK_DataSourceJoin_DataSource]
ALTER TABLE [dbo].[DataSourceColumnJoin] DROP CONSTRAINT [FK_DataSourceColumnJoin_DataSourceColumnSourceCode]
ALTER TABLE [dbo].[DataSourceColumnJoin] DROP CONSTRAINT [FK_DataSourceColumnJoin_DataSourceJoin]