Upgrading a multilanguage, multiportal site from 05.02.02 to 05.04.02, the error below occurred in SQLDataProvider file. When I started the site up there were some serious problems with the configuration of the portals: some portals had no logo, the wrong skin, the wrong home page and the wrong site title.
I rolled back the upgrade and examined the tables in question, and indeed, the PortalLocalization table contained rows for portals now deleted. I presume that was the reason for adding the FK with cascading delete. However, obviously you need to delete orphaned rows before it can be created.
So, I deleted the surplus PortalLocalization records, and upgraded again. That solved the FK issue, but the title of the first portal was still copied to all the other portals, and the logo of some was missing. One site was misconfigured to the point that I couldn't edit the portal settings: it threw an NullReferenceException.
Has anyone encountered similar problems with a multiportal upgrade, and found a solution?
System.Data.SqlClient.SqlException: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_PortalLocalization_Portals". The conflict occurred in database "dotcoma_dnn5", table "dbo.Portals", column 'PortalID'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
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 DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL)
at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions)
/* Add Foreign Key to PortalLocalization Table */
/***********************************************/
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'FK_PortalLocalization_Portals') AND OBJECTPROPERTY(id, N'IsForeignKey') = 1)
BEGIN
/* add key and cascade delete rule */
ALTER TABLE dbo.PortalLocalization
ADD CONSTRAINT FK_PortalLocalization_Portals
FOREIGN KEY ( PortalID ) REFERENCES dbo.Portals ( PortalID ) ON DELETE CASCADE
END