I just upgraded my forum from 1.9.6 to 2.2.2.
During the upgrade process, the following query from constraints.sql kept throwing an exception:
if not exists (select top 1 1 from sys.objects where name='FK_{objectQualifier}TopicReadTracking_{objectQualifier}Topic' and parent_object_id=object_id('[{databaseOwner}].[{objectQualifier}TopicReadTracking]') and type in (N'F'))
alter table [{databaseOwner}].[{objectQualifier}TopicReadTracking] add constraint [FK_{objectQualifier}TopicReadTracking_{objectQualifier}Topic] foreign key (TopicID) references [{databaseOwner}].[{objectQualifier}Topic](TopicID)
go
Running the query manually produced the same exception...
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_yaf_TopicReadTracking_yaf_Topic". The conflict occurred in database "tpa", table "dbo.yaf_Topic", column 'TopicID'.
I am not seeing any existing constraints on yaf_TopicReadTracking (any column) and none with "TopicReadTracking" in the name on yaf_Topics. Curious. I comments it out the ant upgrade succeeded.
I have the same situation now, where I cannot see an existing constraint, and the query still fails.