The main reason for this issue is PegaUVU ruleset got refactored as Pega-UVU in Pega 7.1.8 included in the base product, in old release customers need to import this ruleset separately.
As Upgrade process is removing only Pega- references as shown below not removing any PegaUVU ruleset references, So when it is trying to import the index references it is failing with unique constraint error as both the PegaUVU and Pega-UVU has the same pzinskey.
As a work around you can remove the PegaUVU releated records in the PR_INDEX_REFERENCE table before you trigger the upgrade.
delete from pr_index_reference where pxreferencingrulesetname like'PegaUVU%'
Another problem is , The error logging also did not correctly identify the record that was causing Duplicate entries with PZINSKEY in the PR_INDEX_REFERENCE. The logs was reporting a record ( as problematic ) but actually did not have any problem. So, error logging mechanism as well need to be revisited by Pega.
As a dirty workaround for identifying the problem record, we removed Unique constraint & index on the table and resume the upgrade. The upgrade completed. We ran a GROUP by query on PZINSKEY on the table to identify the exact problematic record.
As suggested, we will remove all the entries related to PegaUVU, then apply back the unique constraint & index and proceed further with Rule object migration.
Until Pega fixes this bug, We will also keep in mind to clean up the PegaUVU entries before the upgrade in subsequent environments.