From aefa96969d96e0005132452612580ebeb039c9ef Mon Sep 17 00:00:00 2001 From: colemanw Date: Sat, 24 Jun 2023 12:42:40 -0700 Subject: [PATCH] Drop unused table civicrm_action_mapping In 2015 this table was made obsolete by the new MappingInterface and has not been used for anything since then. --- CRM/Core/DAO/ActionMapping.php | 393 ------------------ CRM/Core/DAO/AllCoreTables.data.php | 5 - CRM/Upgrade/Incremental/Base.php | 12 + CRM/Upgrade/Incremental/php/FiveSixtyFour.php | 1 + Civi/ActionSchedule/Mapping.php | 1 + .../civicrm_action_mapping.sqldata.php | 65 --- sql/civicrm_generated.mysql | 16 - xml/schema/Core/ActionMapping.xml | 1 + xml/templates/civicrm_data.tpl | 1 - 9 files changed, 15 insertions(+), 480 deletions(-) delete mode 100644 CRM/Core/DAO/ActionMapping.php delete mode 100644 sql/civicrm_data/civicrm_action_mapping.sqldata.php diff --git a/CRM/Core/DAO/ActionMapping.php b/CRM/Core/DAO/ActionMapping.php deleted file mode 100644 index 335dfc2b11..0000000000 --- a/CRM/Core/DAO/ActionMapping.php +++ /dev/null @@ -1,393 +0,0 @@ -__table = 'civicrm_action_mapping'; - parent::__construct(); - } - - /** - * Returns localized title of this entity. - * - * @param bool $plural - * Whether to return the plural version of the title. - */ - public static function getEntityTitle($plural = FALSE) { - return $plural ? ts('Action Mappings') : ts('Action Mapping'); - } - - /** - * Returns all the column names of this table - * - * @return array - */ - public static function &fields() { - if (!isset(Civi::$statics[__CLASS__]['fields'])) { - Civi::$statics[__CLASS__]['fields'] = [ - 'id' => [ - 'name' => 'id', - 'type' => CRM_Utils_Type::T_INT, - 'title' => ts('Action Mapping ID'), - 'required' => TRUE, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_action_mapping.id', - 'table_name' => 'civicrm_action_mapping', - 'entity' => 'ActionMapping', - 'bao' => 'CRM_Core_DAO_ActionMapping', - 'localizable' => 0, - 'html' => [ - 'type' => 'Number', - ], - 'readonly' => TRUE, - 'add' => '3.4', - ], - 'entity' => [ - 'name' => 'entity', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Action Mapping Entity'), - 'description' => ts('Entity for which the reminder is created'), - 'maxlength' => 64, - 'size' => CRM_Utils_Type::BIG, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_action_mapping.entity', - 'table_name' => 'civicrm_action_mapping', - 'entity' => 'ActionMapping', - 'bao' => 'CRM_Core_DAO_ActionMapping', - 'localizable' => 0, - 'add' => '3.4', - ], - 'entity_value' => [ - 'name' => 'entity_value', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Action Mapping Entity Value'), - 'description' => ts('Entity value'), - 'maxlength' => 64, - 'size' => CRM_Utils_Type::BIG, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_action_mapping.entity_value', - 'table_name' => 'civicrm_action_mapping', - 'entity' => 'ActionMapping', - 'bao' => 'CRM_Core_DAO_ActionMapping', - 'localizable' => 0, - 'add' => '3.4', - ], - 'entity_value_label' => [ - 'name' => 'entity_value_label', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Value Label'), - 'description' => ts('Entity value label'), - 'maxlength' => 64, - 'size' => CRM_Utils_Type::BIG, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_action_mapping.entity_value_label', - 'table_name' => 'civicrm_action_mapping', - 'entity' => 'ActionMapping', - 'bao' => 'CRM_Core_DAO_ActionMapping', - 'localizable' => 0, - 'add' => '3.4', - ], - 'entity_status' => [ - 'name' => 'entity_status', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Status'), - 'description' => ts('Entity status'), - 'maxlength' => 64, - 'size' => CRM_Utils_Type::BIG, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_action_mapping.entity_status', - 'table_name' => 'civicrm_action_mapping', - 'entity' => 'ActionMapping', - 'bao' => 'CRM_Core_DAO_ActionMapping', - 'localizable' => 0, - 'add' => '3.4', - ], - 'entity_status_label' => [ - 'name' => 'entity_status_label', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Status Label'), - 'description' => ts('Entity status label'), - 'maxlength' => 64, - 'size' => CRM_Utils_Type::BIG, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_action_mapping.entity_status_label', - 'table_name' => 'civicrm_action_mapping', - 'entity' => 'ActionMapping', - 'bao' => 'CRM_Core_DAO_ActionMapping', - 'localizable' => 0, - 'add' => '3.4', - ], - 'entity_date_start' => [ - 'name' => 'entity_date_start', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Entity Start Date'), - 'description' => ts('Entity date'), - 'maxlength' => 64, - 'size' => CRM_Utils_Type::BIG, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_action_mapping.entity_date_start', - 'table_name' => 'civicrm_action_mapping', - 'entity' => 'ActionMapping', - 'bao' => 'CRM_Core_DAO_ActionMapping', - 'localizable' => 0, - 'add' => '3.4', - ], - 'entity_date_end' => [ - 'name' => 'entity_date_end', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Entity End Date'), - 'description' => ts('Entity date'), - 'maxlength' => 64, - 'size' => CRM_Utils_Type::BIG, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_action_mapping.entity_date_end', - 'table_name' => 'civicrm_action_mapping', - 'entity' => 'ActionMapping', - 'bao' => 'CRM_Core_DAO_ActionMapping', - 'localizable' => 0, - 'add' => '3.4', - ], - 'entity_recipient' => [ - 'name' => 'entity_recipient', - 'type' => CRM_Utils_Type::T_STRING, - 'title' => ts('Entity Recipient'), - 'description' => ts('Entity recipient'), - 'maxlength' => 64, - 'size' => CRM_Utils_Type::BIG, - 'usage' => [ - 'import' => FALSE, - 'export' => FALSE, - 'duplicate_matching' => FALSE, - 'token' => FALSE, - ], - 'where' => 'civicrm_action_mapping.entity_recipient', - 'table_name' => 'civicrm_action_mapping', - 'entity' => 'ActionMapping', - 'bao' => 'CRM_Core_DAO_ActionMapping', - 'localizable' => 0, - 'add' => '3.4', - ], - ]; - CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); - } - return Civi::$statics[__CLASS__]['fields']; - } - - /** - * Return a mapping from field-name to the corresponding key (as used in fields()). - * - * @return array - * Array(string $name => string $uniqueName). - */ - public static function &fieldKeys() { - if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { - Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); - } - return Civi::$statics[__CLASS__]['fieldKeys']; - } - - /** - * Returns the names of this table - * - * @return string - */ - public static function getTableName() { - return self::$_tableName; - } - - /** - * Returns if this table needs to be logged - * - * @return bool - */ - public function getLog() { - return self::$_log; - } - - /** - * Returns the list of fields that can be imported - * - * @param bool $prefix - * - * @return array - */ - public static function &import($prefix = FALSE) { - $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'action_mapping', $prefix, []); - return $r; - } - - /** - * Returns the list of fields that can be exported - * - * @param bool $prefix - * - * @return array - */ - public static function &export($prefix = FALSE) { - $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'action_mapping', $prefix, []); - return $r; - } - - /** - * Returns the list of indices - * - * @param bool $localize - * - * @return array - */ - public static function indices($localize = TRUE) { - $indices = []; - return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; - } - -} diff --git a/CRM/Core/DAO/AllCoreTables.data.php b/CRM/Core/DAO/AllCoreTables.data.php index 9251e2b752..31b51fb7ac 100644 --- a/CRM/Core/DAO/AllCoreTables.data.php +++ b/CRM/Core/DAO/AllCoreTables.data.php @@ -67,11 +67,6 @@ return [ 'class' => 'CRM_Core_DAO_PrevNextCache', 'table' => 'civicrm_prevnext_cache', ], - 'CRM_Core_DAO_ActionMapping' => [ - 'name' => 'ActionMapping', - 'class' => 'CRM_Core_DAO_ActionMapping', - 'table' => 'civicrm_action_mapping', - ], 'CRM_Core_DAO_RecurringEntity' => [ 'name' => 'RecurringEntity', 'class' => 'CRM_Core_DAO_RecurringEntity', diff --git a/CRM/Upgrade/Incremental/Base.php b/CRM/Upgrade/Incremental/Base.php index 81214edd06..68e04644f7 100644 --- a/CRM/Upgrade/Incremental/Base.php +++ b/CRM/Upgrade/Incremental/Base.php @@ -563,6 +563,18 @@ class CRM_Upgrade_Incremental_Base { return TRUE; } + /** + * Drop a table if it exists. + * + * @param CRM_Queue_TaskContext $ctx + * @param string $tableName + * @return bool + */ + public static function dropTable($ctx, $tableName) { + CRM_Core_BAO_SchemaHandler::dropTable($tableName); + return TRUE; + } + /** * Drop a table... but only if it's empty. * diff --git a/CRM/Upgrade/Incremental/php/FiveSixtyFour.php b/CRM/Upgrade/Incremental/php/FiveSixtyFour.php index 10d18a85d0..6cf0f09ec5 100644 --- a/CRM/Upgrade/Incremental/php/FiveSixtyFour.php +++ b/CRM/Upgrade/Incremental/php/FiveSixtyFour.php @@ -30,6 +30,7 @@ class CRM_Upgrade_Incremental_php_FiveSixtyFour extends CRM_Upgrade_Incremental_ public function upgrade_5_64_alpha1($rev): void { $this->addTask('Add priority column onto ACL table', 'addColumn', 'civicrm_acl', 'priority', 'int NOT NULL DEFAULT 0'); $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); + $this->addTask('Drop unused civicrm_action_mapping table', 'dropTable', 'civicrm_action_mapping'); $this->addTask('Update post_URL/cancel_URL in logging tables', 'updateLogging'); $this->addTask('Add in Everybody ACL Role option value', 'addEveryBodyAclOptionValue'); } diff --git a/Civi/ActionSchedule/Mapping.php b/Civi/ActionSchedule/Mapping.php index 2c092ddcea..948fcf5389 100644 --- a/Civi/ActionSchedule/Mapping.php +++ b/Civi/ActionSchedule/Mapping.php @@ -37,6 +37,7 @@ namespace Civi\ActionSchedule; * The new MappingInterface makes no pretense of database-driven * configuration. The dozen places have been consolidated and * replaced with functions in MappingInterface. + * The unused `civicrm_action_mapping` table has been dropped. * * This "Mapping" implementation is a refactoring of the old * hard-coded bits. Internally, it uses the concepts from diff --git a/sql/civicrm_data/civicrm_action_mapping.sqldata.php b/sql/civicrm_data/civicrm_action_mapping.sqldata.php deleted file mode 100644 index c9346eaa1a..0000000000 --- a/sql/civicrm_data/civicrm_action_mapping.sqldata.php +++ /dev/null @@ -1,65 +0,0 @@ -addValues([ - [ - 'entity' => 'civicrm_activity', - 'entity_value' => 'activity_type', - 'entity_value_label' => 'Activity Type', - 'entity_status' => 'activity_status', - 'entity_status_label' => 'Activity Status', - 'entity_date_start' => 'activity_date_time', - 'entity_date_end' => NULL, - 'entity_recipient' => 'activity_contacts', - ], - [ - 'entity' => 'civicrm_participant', - 'entity_value' => 'event_type', - 'entity_value_label' => 'Event Type', - 'entity_status' => 'civicrm_participant_status_type', - 'entity_status_label' => 'Participant Status', - 'entity_date_start' => 'event_start_date', - 'entity_date_end' => 'event_end_date', - 'entity_recipient' => 'event_contacts', - ], - [ - 'entity' => 'civicrm_participant', - 'entity_value' => 'civicrm_event', - 'entity_value_label' => 'Event Name', - 'entity_status' => 'civicrm_participant_status_type', - 'entity_status_label' => 'Participant Status', - 'entity_date_start' => 'event_start_date', - 'entity_date_end' => 'event_end_date', - 'entity_recipient' => 'event_contacts', - ], - [ - 'entity' => 'civicrm_membership', - 'entity_value' => 'civicrm_membership_type', - 'entity_value_label' => 'Membership Type', - 'entity_status' => 'auto_renew_options', - 'entity_status_label' => 'Auto Renew Options', - 'entity_date_start' => 'membership_join_date', - 'entity_date_end' => 'membership_end_date', - 'entity_recipient' => NULL, - ], - [ - 'entity' => 'civicrm_participant', - 'entity_value' => 'event_template', - 'entity_value_label' => 'Event Template', - 'entity_status' => 'civicrm_participant_status_type', - 'entity_status_label' => 'Participant Status', - 'entity_date_start' => 'event_start_date', - 'entity_date_end' => 'event_end_date', - 'entity_recipient' => 'event_contacts', - ], - [ - 'entity' => 'civicrm_contact', - 'entity_value' => 'civicrm_contact', - 'entity_value_label' => 'Date Field', - 'entity_status' => 'contact_date_reminder_options', - 'entity_status_label' => 'Annual Options', - 'entity_date_start' => 'date_field', - 'entity_date_end' => NULL, - 'entity_recipient' => NULL, - ], - ]); diff --git a/sql/civicrm_generated.mysql b/sql/civicrm_generated.mysql index d50bcfc1bb..c16a9fb334 100644 --- a/sql/civicrm_generated.mysql +++ b/sql/civicrm_generated.mysql @@ -66,22 +66,6 @@ LOCK TABLES `civicrm_action_log` WRITE; /*!40000 ALTER TABLE `civicrm_action_log` ENABLE KEYS */; UNLOCK TABLES; --- --- Dumping data for table `civicrm_action_mapping` --- - -LOCK TABLES `civicrm_action_mapping` WRITE; -/*!40000 ALTER TABLE `civicrm_action_mapping` DISABLE KEYS */; -INSERT INTO `civicrm_action_mapping` (`id`, `entity`, `entity_value`, `entity_value_label`, `entity_status`, `entity_status_label`, `entity_date_start`, `entity_date_end`, `entity_recipient`) VALUES - (1,'civicrm_activity','activity_type','Activity Type','activity_status','Activity Status','activity_date_time',NULL,'activity_contacts'), - (2,'civicrm_participant','event_type','Event Type','civicrm_participant_status_type','Participant Status','event_start_date','event_end_date','event_contacts'), - (3,'civicrm_participant','civicrm_event','Event Name','civicrm_participant_status_type','Participant Status','event_start_date','event_end_date','event_contacts'), - (4,'civicrm_membership','civicrm_membership_type','Membership Type','auto_renew_options','Auto Renew Options','membership_join_date','membership_end_date',NULL), - (5,'civicrm_participant','event_template','Event Template','civicrm_participant_status_type','Participant Status','event_start_date','event_end_date','event_contacts'), - (6,'civicrm_contact','civicrm_contact','Date Field','contact_date_reminder_options','Annual Options','date_field',NULL,NULL); -/*!40000 ALTER TABLE `civicrm_action_mapping` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Dumping data for table `civicrm_action_schedule` -- diff --git a/xml/schema/Core/ActionMapping.xml b/xml/schema/Core/ActionMapping.xml index c646932245..a01d9f9b02 100644 --- a/xml/schema/Core/ActionMapping.xml +++ b/xml/schema/Core/ActionMapping.xml @@ -6,6 +6,7 @@ civicrm_action_mapping Table to store mapping for the reminder. 3.4 + 5.64 id Action Mapping ID diff --git a/xml/templates/civicrm_data.tpl b/xml/templates/civicrm_data.tpl index 6905e93538..6164992821 100644 --- a/xml/templates/civicrm_data.tpl +++ b/xml/templates/civicrm_data.tpl @@ -94,7 +94,6 @@ SELECT @domainID := id FROM civicrm_domain where name = 'Default Domain Name'; {php}echo (include "sql/civicrm_data/civicrm_uf_join.sqldata.php")->toSQL();{/php} {php}echo (include "sql/civicrm_data/civicrm_uf_field.sqldata.php")->toSQL();{/php} {php}echo (include "sql/civicrm_data/civicrm_participant_status_type.sqldata.php")->toSQL();{/php} -{php}echo (include "sql/civicrm_data/civicrm_action_mapping.sqldata.php")->toSQL();{/php} {php}echo (include "sql/civicrm_data/civicrm_contact_type.sqldata.php")->toSQL();{/php} {include file='civicrm_msg_template.tpl'} -- 2.25.1