Deploy Error: Foreign Key Constraint in cmsContentType (Umbraco Cloud, v13.7.0)

(Full stack trace included below)


Setup

  • Umbraco Version: 13.7.0
  • Umbraco Cloud: Yes
  • Target Environment: Dev
  • Local Framework: .NET 8
  • ModelsBuilder: Using Umbraco.ModelsBuilder.Embedded v13.7.0

What I Did

  1. Created a new document type (EmailTemplate) in Umbraco Backoffice without a template.
  2. Developed my feature, a new email flow. Tested and made it work.
  3. Pushed the changes to Umbraco Cloud using Deploy.
  4. I attempted to transfer my content from the root node and from the folder, via queue for transfer.
  5. The error occurred during the deployment process.

What I Have Tried

:white_check_mark: Checked document types in Backoffice: EmailTemplate exists locally.
:white_check_mark: Synced local changes with Cloud.
:white_check_mark: Made a small change to be able to re-push to dev and trigger a build.


Stack Trace

{
  "Date": "2025-03-07T12:14:55.9974265+00:00",
  "Message": "The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_cmsContentTypeAllowedContentType_cmsContentType1\". The conflict occurred in database \"pwltd2fmzwv\", table \"dbo.cmsContentType\", column 'nodeId'.\r\nThe statement has been terminated.",
  "Ex": {
    "ClassName": "Microsoft.Data.SqlClient.SqlException",
    "Message": "The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_cmsContentTypeAllowedContentType_cmsContentType1\". The conflict occurred in database \"pwltd2fmzwv\", table \"dbo.cmsContentType\", column 'nodeId'.\r\nThe statement has been terminated.",
    "Data": {
      "HelpLink.ProdName": "Microsoft SQL Server",
      "HelpLink.ProdVer": "12.00.0220",
      "HelpLink.EvtSrc": "MSSQLServer",
      "HelpLink.EvtID": "547",
      "HelpLink.BaseHelpUrl": "https://go.microsoft.com/fwlink",
      "HelpLink.LinkId": "20476",
      "SqlError 1": "Microsoft.Data.SqlClient.SqlError: The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_cmsContentTypeAllowedContentType_cmsContentType1\". The conflict occurred in database \"pwltd2fmzwv\", table \"dbo.cmsContentType\", column 'nodeId'.",
      "SqlError 2": "Microsoft.Data.SqlClient.SqlError: The statement has been terminated."
    },
    "InnerException": null,
    "HelpURL": null,
    "StackTraceString": "   at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)\r\n   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)\r\n   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, SqlCommand command, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\r\n   at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)\r\n   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)\r\n   at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)\r\n   at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery()\r\n   at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)\r\n   at NPoco.Database.ExecuteNonQueryHelper(DbCommand cmd)\r\n   at NPoco.Database.InsertAsyncImp[T](PocoData pocoData, String tableName, String primaryKeyName, Boolean autoIncrement, T poco, Boolean sync)\r\n   at NPoco.AsyncHelper.RunSync[T](Task`1 task)\r\n   at NPoco.Database.Insert[T](String tableName, String primaryKeyName, Boolean autoIncrement, T poco)\r\n   at NPoco.Database.Insert[T](T poco)\r\n   at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentTypeRepositoryBase`1.PersistUpdatedBaseContentType(IContentTypeComposition entity)\r\n   at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentTypeRepository.PersistUpdatedItem(IContentType entity)\r\n   at Umbraco.Cms.Core.Cache.FullDataSetRepositoryCachePolicy`2.Update(TEntity entity, Action`1 persistUpdated)\r\n   at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.EntityRepositoryBase`2.Save(TEntity entity)\r\n   at Umbraco.Cms.Core.Services.ContentTypeServiceBase`2.Save(TItem item, Int32 userId)\r\n   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ContentTypeConnector.DocumentTypeConnector.SaveContentType(IContentType contentType, Int32 userId)\r\n   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ContentTypeConnector.ContentTypeConnectorBase`2.Pass1(DeployState state, IDeployContext context)\r\n   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ContentTypeConnector.ContentTypeConnectorBase`2.Process(DeployState state, IDeployContext context, Int32 pass)\r\n   at Umbraco.Deploy.Infrastructure.Connectors.ServiceConnectors.ServiceConnectorBase`3.Process(ArtifactDeployState dart, IDeployContext context, Int32 pass)\r\n   at Umbraco.Deploy.Infrastructure.Environments.CurrentEnvironment.ProcessArtifacts(IEnumerable`1 arts, String ownerEmail, IDeployContext context, CancellationToken token)",
    "RemoteStackTraceString": null,
    "RemoteStackIndex": 0,
    "ExceptionMethod": null,
    "HResult": -2146232060,
    "Source": "Core Microsoft SqlClient Data Provider",
    "WatsonBuckets": null,
    "Errors": null,
    "ClientConnectionId": "3d49347d-8aad-4a77-8fc1-4cd76bb74d7c"
  },
  "Sender": "Umbraco.Deploy.Infrastructure.Work.WorkItems.DiskReadWorkItem"
}
1 Like

Is it possible the deploy schema files aren’t fully synced up? You might also find some hints in the Umbraco logs as well perhaps…

2 Likes

In the end it turned out to be a corrupted data type causing the errors.
I solved it by

  • Copying the datatype
  • Delete the original
  • Using the copy
  • Deploy to my dev environemt
  • Going to Settings > Deploy > Update Umbraco Schema

And that fixed my issue :slight_smile:

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.