Get rid of `civicrm_option_value.domain_id`
Background/Motivation
Most tables with a domain_id
column have that field required for every record.
civicrm_option_value
is an outlier; most option groups don't care about domains. In fact there are only two that do:
/**
* $_domainIDGroups array maintains the list of option groups for whom
* domainID is to be considered.
*
* FIXME: Hardcoded list = bad. It would be better to make this a column in the civicrm_option_group table
* @var array
*/
public static $_domainIDGroups = [
'from_email_address',
'grant_type',
];
The civicrm_option_value.domain_id
column and that lovely accompanying hardcoded list were added in this commit as part of this issue. The assumption at the time seemed to be that the list might grow in the future, but that's proven to not be the case. Instead, we have this extra column making the already overloaded civicrm_option_value
table even more complex to deal with. It would have been better at the time to move those two option groups into their own tables. It may not be too late to do so.
Proposal
- Create a new table
civicrm_grant_type
- manage that table from thecivigrant
extension. - Create a new table
civicrm_from_email_address
. - Migrate all options into the new tables. Update pseudoconstant metadata in the schema.
- Add some legacy handling at a few key points like
civicrm_api()
&CRM_Core_OptionGroup::values()
to fetch options from the new table, for backward compatibility. - Deprecate the
civicrm_option_value.domain_id
column and eventually drop it.