Hello, I attempted a test upgrade of my 4.0.3 site to 4.3.5 and had 2 apparently related errors in 2 different SQL upgrade scripts. Before I attempt to resolve, I am wondering if anyone else has seen the same or similar error and what a possible resolution is.
In the 04.00.04.log file it indicates an error altering the Folders table
System.Data.SqlClient.SqlException: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_{objectqualifier}Files_{objectqualifier}Folders". The conflict occurred in database "DBName", table "dbo.{objectqualifier}Folders", column 'FolderID'.
Using this SQL:
If (SELECT {databaseOwner}{objectQualifier}fn_GetVersion(3,2,3)) = 0
BEGIN
ALTER TABLE {databaseOwner}{objectQualifier}Files ADD CONSTRAINT
FK_{objectQualifier}Files_{objectQualifier}Folders FOREIGN KEY
(
FolderID
) REFERENCES {databaseOwner}{objectQualifier}Folders
(
FolderID
)
END
And in the 4.03.01 log:
System.Data.SqlClient.SqlException: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_{objectqualifier}Files_{objectqualifier}Folders". The conflict occurred in database "DBName", table "dbo.{objectqualifier}Folders", column 'FolderID'.
Using this SQL:
/* This tries to apply a foreign key on the files/folders tables */
/*****************************************************************/
IF NOT EXISTS ( SELECT * FROM sysobjects WHERE id = object_id(N'FK_{objectQualifier}Files_{objectQualifier}Folders') AND OBJECTPROPERTY(id, N'IsForeignKey') = 1)
BEGIN
ALTER TABLE {databaseOwner}{objectQualifier}Files ADD CONSTRAINT
FK_{objectQualifier}Files_{objectQualifier}Folders FOREIGN KEY
(
FolderID
) REFERENCES {databaseOwner}{objectQualifier}Folders
(
FolderID
)
END
Any thoughts or recommendations are appreciated.
Thank you,
Rob Ralston