5.21-RC upgrade fails if there are similar-named Option Groups
On civicrm.org we ran into a fatal error due to:
CRM_Upgrade_Incremental_php_FiveTwentyOne::fixOptionGroupName()
Error message:
UPDATE civicrm_option_group SET name = 'numeric_rating' WHERE ( civicrm_option_group.id = 357 )
[nativecode=1062 ** Duplicate entry 'numeric_rating' for key 'UI_name']
Pre-upgrade data:
> select * from civicrm_option_group where name like '%numeric%';
+-----+-------------------------------+----------------+----------------------------+-------------+-----------+-----------+-----------+
| id | name | title | description | is_reserved | is_active | is_locked | data_type |
+-----+-------------------------------+----------------+----------------------------+-------------+-----------+-----------+-----------+
| 357 | Numeric Rating | Numeric Rating | numeric rating from 1 to 5 | 1 | 1 | 0 | Integer |
| 358 | numeric_rating | Numeric Rating | NULL | 1 | 1 | 0 | Integer |
| 359 | numeric_rating_20171003141125 | Numeric rating | NULL | 0 | 1 | 0 | String |
+-----+-------------------------------+----------------+----------------------------+-------------+-----------+-----------+-----------+
To make matters worse, the id=357 group does not have an option values. I have no idea where it's used. (and exists from before enabling detailed-log, 2019-02)
Nonetheless, I feel like this should require a pre-upgrade check?
cc @seamuslee