Wednesday 15 December 2010

The DELETE statement conflicted with the REFERENCE constraint "FK_cmsPreviewXml_cmsContentVersion". - Swap Master Doc Type Error in Umbraco

Today is my day of Umbraco database hell!

I tried to swap a master doc type. I clicked ok, confirm, yes, ok etc and then nothing!

I looked into the error logs and came cross this:


At /umbraco/theoutfield/doctypeextensions/dialogs/SwapMasterDocType.aspx?id=1071&rndo=27.8 (Referred by: http://localhost/umbraco/theoutfield/doctypeextensions/dialogs/SwapMasterDocType.aspx?id=1071&rndo=27.8): System.Data.SqlClient.SqlException: The DELETE statement conflicted with the REFERENCE constraint "FK_cmsPreviewXml_cmsContentVersion". The conflict occurred in database "LOTUS_DEV", table "dbo.cmsPreviewXml", column 'versionId'. The DELETE statement conflicted with the REFERENCE constraint "FK_cmsPreviewXml_cmsContentVersion". The conflict occurred in database "LOTUS_DEV", table "dbo.cmsPreviewXml", column 'versionId'. The DELETE statement conflicted with the REFERENCE constraint "FK_cmsPreviewXml_cmsContentVersion". The conflict occurred in database "LOTUS_DEV", table "dbo.cmsPreviewXml", column 'versionId'. The statement has been terminated. The statement has been terminated. The statement has been terminated. at System.Data.SqlClient.SqlConnection.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 TheOutfield.UmbExt.DocTypeExtensions.Dialogs.SwapMasterDocType.DoSwitch() at TheOutfield.UmbExt.DocTypeExtensions.Dialogs.SwapMasterDocType.btnConfirm_Click(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)



The solution is identical to my previous post...

Open up SQL Management Studio.
Change delete rule for the relationship between cmsPreviewXml and cmsContentVersionto "cascade".


Now you can swap those master doc types!



No comments:

Post a Comment