Attempting to move a custom field of type Country bypasses extends check and fails
Moving custom fields that are extended from two different types (e.g. individual to membership) is not allowed by code. The check works fine for alphanumeric fields, properly showing an error in the UI. However, when attempting to move a field with a type of Country, the check appears to be bypassed or is not working for some reason. The system attempts to begin database alter statements, failing in the background, while the CiviCRM logo endlessly spins in UI.
This is one error that was thrown during that attempt:
[nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`dbname`.`civicrm_value_individual_me_1`, CONSTRAINT `FK_civicrm_value_individual_me_1_entity_id`
FOREIGN KEY (`entity_id`) REFERENCES `civicrm_membership` (`id`) ON DELETE CASCADE)]
This appears to be the check that works for alphanumeric fields, but is not being thrown for Country fields: https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/BAO/CustomField.php#L2007