Error Upgrading Test Manager Due To DB Constraint Conflicts

Why is Test Manager upgrade failing at the database configuration step?

Issue Description: Sometimes, the Test Manager upgrade fails at the DB configuration step. This has been particularly observed while upgrading from v21.4 to v21.10.

The error in the installation logs looks like the below,


Root Cause: This error occurs due to an issue with the DB migration that causes failure to create the required Foreign Key( FK) constraint since the "tmOrch.Folders" table does not have the folder which is mapped to the "tmOrch.LinkedTestSets" for some reason. This is under further investigation.

Resolution:

  1. As a first step to resolve this, try to restore database from the backup and begin the upgrade process afresh. This would be the foremost recommended approach towards resolution since it would ensure the robustness of the product in the long run, so that a similar situation can be avoided during the future upgrades.

  1. If the above step does not resolve the issue, It is required to resolve the conflicts manually via SQL queries. Note to take a proper backup and perform the actions under the supervision of a DBA.

  1. Select everything from table "tmOrch.LinkedTestSets" by running a SELECT * query in the TM DB -->Make a note of the IDs for the resultant rows
  2. Next, open table "tmOrch.Folders" and again run a SELECT * query to view all the contents inside --> Compare the folder IDs with that present in the "tmOrch.LinkedTestSets" table, and make a note of the missing folder ID
  3. Open Orchestrator DB/UI at the background and make a note of the name of the folder with the missing ID
  4. Run the below INSERT query to insert the record for the missing folder into the "tmOrch.Folders" table:

INSERT INTO tmorch.Folders (id, DisplayName, IsActive, DoImport, TenantId)

values ( {ID of the missing folder from step-2}, '{Name of the missing folder from step-3}', 1, {Tenant ID from the tmOrch.Folders table} )

(NOTE: The bolded entries in the query above have to replaced along with the curly braces)

  1. After performing the above steps, re-run the upgrade process and it should run seamlessly.

Since making manual DB changes in not a recommended approach towards resolution, the above should be considered more of a workaround.