Kentico v9.0.46 to 10.x upgrade fail

Eric Garrison asked on January 14, 2017 02:46

My upgrade from v8 to 10 failed. It looks like the script got most of the way complete. I have tried to run these scripts manually, and they fail also.

SQL script applied. 90% of SQL script applied. 80% of SQL script applied. 70% of SQL script applied. 60% of SQL script applied. 50% of SQL script applied. 40% of SQL script applied. 30% of SQL script applied. 20% of SQL script applied. 10% of SQL script applied.

-- Update table [OM_PersonalizationVariant] ALTER TABLE [OM_PersonalizationVariant] ADD CONSTRAINT [FK_OM_PersonalizationVariant_VariantPageTemplateID_CMS_PageTemplate] FOREIGN KEY ([VariantPageTemplateID]) REFERENCES [CMS_PageTemplate] ([PageTemplateID]), CONSTRAINT [FK_OM_PersonalizationVariant_VariantDocumentID_CMS_Document] FOREIGN KEY ([VariantDocumentID]) REFERENCES [CMS_Document] ([DocumentID]);

CREATE NONCLUSTERED INDEX [IX_OM_PersonalizationVariant_VariantDocumentID] ON [OM_PersonalizationVariant] ([VariantPageTemplateID]) ON [PRIMARY];

CREATE NONCLUSTERED INDEX [IX_OM_PersonalizationVariant_VariantPageTemplateID] ON [OM_PersonalizationVariant] ([VariantDocumentID]) ON [PRIMARY];

Failed to run SQLscript:

-- Update table [OM_PersonalizationVariant] ALTER TABLE [OM_PersonalizationVariant] ADD CONSTRAINT [FK_OM_PersonalizationVariant_VariantPageTemplateID_CMS_PageTemplate] FOREIGN KEY ([VariantPageTemplateID]) REFERENCES [CMS_PageTemplate] ([PageTemplateID]), CONSTRAINT [FK_OM_PersonalizationVariant_VariantDocumentID_CMS_Document] FOREIGN KEY ([VariantDocumentID]) REFERENCES [CMS_Document] ([DocumentID]);

CREATE NONCLUSTERED INDEX [IX_OM_PersonalizationVariant_VariantDocumentID] ON [OM_PersonalizationVariant] ([VariantPageTemplateID]) ON [PRIMARY];

CREATE NONCLUSTERED INDEX [IX_OM_PersonalizationVariant_VariantPageTemplateID] ON [OM_PersonalizationVariant] ([VariantDocumentID]) ON [PRIMARY];

Caused exception: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_OM_PersonalizationVariant_VariantDocumentID_CMS_Document". The conflict occurred in database "DEV_Kentico9", table "dbo.CMS_Document", column 'DocumentID'.

Message:

-- Update table [OM_PersonalizationVariant] ALTER TABLE [OM_PersonalizationVariant] ADD CONSTRAINT [FK_OM_PersonalizationVariant_VariantPageTemplateID_CMS_PageTemplate] FOREIGN KEY ([VariantPageTemplateID]) REFERENCES [CMS_PageTemplate] ([PageTemplateID]), CONSTRAINT [FK_OM_PersonalizationVariant_VariantDocumentID_CMS_Document] FOREIGN KEY ([VariantDocumentID]) REFERENCES [CMS_Document] ([DocumentID]);

CREATE NONCLUSTERED INDEX [IX_OM_PersonalizationVariant_VariantDocumentID] ON [OM_PersonalizationVariant] ([VariantPageTemplateID]) ON [PRIMARY];

CREATE NONCLUSTERED INDEX [IX_OM_PersonalizationVariant_VariantPageTemplateID] ON [OM_PersonalizationVariant] ([VariantDocumentID]) ON [PRIMARY];

Caused exception: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_OM_PersonalizationVariant_VariantDocumentID_CMS_Document". The conflict occurred in database "DEV_Kentico9", table "dbo.CMS_Document", column 'DocumentID'.

Stack Trace: at CMS.DataEngine.AbstractDataConnection.HandleError(String queryText, Exception ex) at CMS.DataEngine.AbstractDataConnection.ExecuteNonQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction) at Hotfix.Installer.HotfixHelper.RunSQLCommand(String text, IDataConnection connection) at Hotfix.Installer.HotfixHelper.RunSQLScript(String fileName, String connString, String defaultUICulture, IMessageLog messageLog) The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_OM_PersonalizationVariant_VariantDocumentID_CMS_Document". The conflict occurred in database "DEV_Kentico9", table "dbo.CMS_Document", column 'DocumentID'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at CMS.DataEngine.AbstractDataConnection.ExecuteNonQuery(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction)

Running SQL script (upgrade.sql) DLLs\Net45\Azure DLLs\Net45\Azure DLLs\Net45 DLLs\Net45 CMS_PROJ CMS_PROJ\CMS CMS_PROJ\CMS\CMSWebParts

Correct Answer

Michal Samuhel answered on January 14, 2017 07:38

Hi Eric,

Based on the error you are getting I would tell, that there is a personalization variant for a document which does no longer exist. You can check OM_PersonalizationVariant VariantDocumentID column with CMS_Document DocumentID column and it seems that one or more variantDocumentID does not have a document with this ID. You will need to remove these variants.

Also please be aware that there were quite some changes in OM to v10 so please also check:

https://docs.kentico.com/k10/installation/upgrading-to-kentico-10

1 votesVote for this answer Unmark Correct answer

Recent Answers


Eric Garrison answered on January 14, 2017 22:02

We are not even using OM / Personalization. It looks like this came from Goat Demo site I think. There are only 4 rows of data in that table. My plan is to delete the demo sites, truncate that table and re-run upgrade.

Thanks for the assist Michal.

0 votesVote for this answer Mark as a Correct answer

Michal Samuhel answered on January 17, 2017 13:10

You are welcome Eric.

Just an update if anybody encounters similar issue. Eric was correct and if you had installed sample sites, especially dancing goat some OM features will be imported as dancing goat serves as a presentation for all EMS functionality(A/B tests, MVT testing, personalization) and this may cause issues even if you switch to lower level license as some page templates are part of MVT tests etc.

0 votesVote for this answer Mark as a Correct answer

Eric Garrison answered on January 17, 2017 14:24

Deleting the Dancing Goat demo did not fix the issue. Truncating that table, to remove those 4 rows, did fix the problem. After that table was clean, the upgrade ran fine.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.