"Cannot insert the value NULL into column 'Path'; table 'OrganizationUnits' column does not allow nulls" Error

When upgrading the Orchestrator to 23.10.3, the following error is thrown "Cannot insert the value NULL into column 'Path', table 'dbo.OrganizationUnits' column does not allow nulls."

Issue Description

When upgrading the Orchestrator to the 2023.10.x version, the error "System.Exception: Migration failed: Cannot insert the value NULL into column 'Path', table 'dbo.OrganizationUnits'; column does not allow nulls." is shown. The update fails and the update process rolls back on hitting the 'OK' button.

On checking the database 'dbo.OrganizationUnits' table before the rollback, some rows have the 'Path' column with NULL value.

A PATH could not be created because of missing Parent Key and/or the CODE column does not contain the entire chain values of the parents.

Resolution

Follow the steps below:

  1. Identify the rows with 'NULL' value in the 'Path' column and check its Key alongside with the ParentKeys.
  2. To identify the parents of your OU, check the 'ParentID' column.
  3. Once identified the OU chain, update the missing/NULL Parent Keys with the appropriate keys.
  4. Make sure the 'Code' column also follows the correct parent chain as well, as explained below.

Example:

As shown in the screenshot below, OU Id 14 has as a Parent OU Id 10 which also has a ParentId 33. You can see that OU 14 doesn't have a ParentKey, so 'NULL' value should be replaced with the key from OU Id 10. Id 33 is the first level parent hence it does not have a ParentID, so the ParentKey will be 'NULL'.

The 'Code' value of OU 14 does not contain the full hierarchical chain.

The value will be added manually and will contain the full hierarchical chain.

Example:

'0000000006.0000000002.0000000004.0000000001'

After correcting all the rows, restart the upgrade process.

Note: A full database backup is recommended before performing any changes or starting and upgrade / migration process.