Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Rud 232 posts 902 karma points c-trib
    Feb 04, 2024 @ 19:07
    Martin Rud
    0

    Minor upgrade v.8: "'FK_umbracoRedirectUrl_umbracoNode_uniqueID' is not a constraint. Could not drop constraint."

    Hi forum,

    When trying to upgrade v8.9.1 to 8.18.12 it work fine on my local dev (Umbraco.sdf), but in production (MSSQL) I get this error during upgrade:

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Umbraco.Web.Install.InstallException: The database failed to upgrade. ERROR: The database configuration failed with the following message: 'FK_umbracoRedirectUrl_umbracoNode_uniqueID' is not a constraint.\r\nCould not drop constraint. See previous errors.\n Please check log file for additional information (can be found in '/App_Data/Logs/')\r\n   at Umbraco.Web.Install.InstallSteps.DatabaseUpgradeStep.ExecuteAsync(Object model)\r\n   --- End of inner exception stack trace ---\r\n   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)\r\n   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)\r\n   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n   at Umbraco.Web.Install.Controllers.InstallApiController.<ExecuteStepAsync>d__14.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Umbraco.Web.Install.Controllers.InstallApiController.<PostPerformInstall>d__11.MoveNext()"
    

    I have tried adding and removing constraints, but I just f... things more up.... :)

    Can anyone help me?

  • Arjun Singh 15 posts 86 karma points
    Feb 05, 2024 @ 07:49
    Arjun Singh
    0

    This query can give you list of constraints which are unique and relative to upgrade.

     SELECT  'DROP INDEX [' + IX.NAME + '] ON ' + OBJECT_NAME(IX.OBJECT_ID) + '; '
    FROM  SYS.INDEXES IX
      JOIN SYS.OBJECTS O ON  IX.OBJECT_ID = O.OBJECT_ID
      INNER JOIN SYS.SCHEMAS S ON O.SCHEMA_ID = S.SCHEMA_ID
    WHERE 
      IX.NAME IS NOT NULL 
      AND O.TYPE <> 'S' 
      AND IS_PRIMARY_KEY <> 1 
      AND INDEX_ID > 0
      AND S.NAME != 'SYS' AND S.NAME!= 'SYS' AND IS_UNIQUE_CONSTRAINT = 1
    

    Also check on the App_Data/logs , what is the exact SQL query that upgrade is attempting.

    once you get the query , you can map the values to below Query , this will generate you the alter sql statement for all the dependent constraints.

     SELECT 'ALTER TABLE [' + object_name(f.parent_object_id) + '] DROP CONSTRAINT  [' + f.name + ']; '
    From
    sys.foreign_keys f
    inner join
    sys.indexes i
    on f.referenced_object_id = i.object_id and
    f.key_index_id = i.index_id
    Where
    i.name = 'PK_user' and
    i.object_id = object_id('[dbo].[umbracoUser]')
    
  • Justin Neville 22 posts 196 karma points c-trib
    Feb 05, 2024 @ 12:31
  • Martin Rud 232 posts 902 karma points c-trib
    Feb 05, 2024 @ 12:45
    Martin Rud
    0

    Thanks, it did indeed help :)

    More precisely Sams solution: https://our.umbraco.com/forum/using-umbraco-and-getting-started/106748-cant-upgrade-from-umbraco-8141-to-8151#comment-333239 (which as also marked as solution):

    ALTER TABLE umbracoRedirectUrl WITH NOCHECK
    ADD CONSTRAINT FK_umbracoRedirectUrl_umbracoNode_uniqueID CHECK (contentKey <> '') ;
    
    ALTER TABLE umbracoNode
    DROP CONSTRAINT IX_umbracoNode_UniqueId
    
Please Sign in or register to post replies

Write your reply to:

Draft