From b676923b3f59c13f9fb7837f6ba34a953ce08b75 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Thu, 21 Mar 2013 21:27:47 +0530 Subject: [PATCH] --fixed for CRM-12141 --- CRM/Upgrade/Incremental/php/FourThree.php | 29 ++++++++++++++++++++ xml/schema/Financial/EntityFinancialTrxn.xml | 10 +++++++ 2 files changed, 39 insertions(+) diff --git a/CRM/Upgrade/Incremental/php/FourThree.php b/CRM/Upgrade/Incremental/php/FourThree.php index c1a9c93cfb..c1866a363f 100644 --- a/CRM/Upgrade/Incremental/php/FourThree.php +++ b/CRM/Upgrade/Incremental/php/FourThree.php @@ -139,6 +139,9 @@ WHERE entity_value = '' OR entity_value IS NULL function upgrade_4_3_alpha1($rev) { self::task_4_3_alpha1_checkDBConstraints(); + // add indexes for civicrm_entity_financial_trxn + // CRM-12141 + $this->addTask(ts('Check/Add indexes for civicrm_entity_financial_trxn'), 'task_4_3_x_checkIndexes', $rev); // task to process sql $this->addTask(ts('Upgrade DB to 4.3.alpha1: SQL'), 'task_4_3_x_runSql', $rev); @@ -206,6 +209,9 @@ WHERE entity_value = '' OR entity_value IS NULL function upgrade_4_3_beta4($rev) { $this->addTask(ts('Upgrade DB to 4.3.beta4: SQL'), 'task_4_3_x_runSql', $rev); + // add indexes for civicrm_entity_financial_trxn + // CRM-12141 + $this->addTask(ts('Check/Add indexes for civicrm_entity_financial_trxn'), 'task_4_3_x_checkIndexes', $rev); } //CRM-11636 @@ -348,6 +354,9 @@ FROM civicrm_entity_financial_account ceft INNER JOIN civicrm_option_group cog ON cog.id = cov.option_group_id WHERE cog.name = 'payment_instrument'"; CRM_Core_DAO::executeQuery($sql); + //CRM-12141 + $sql = "ALTER TABLE {$tempTableName1} ADD INDEX index_instrument_id (instrument_id);"; + CRM_Core_DAO::executeQuery($sql); //create temp table to process completed / cancelled contribution $tempTableName2 = CRM_Core_DAO::createTempTableName(); @@ -379,6 +388,9 @@ FROM civicrm_contribution con ON con.payment_instrument_id = tpi.instrument_id WHERE con.contribution_status_id IN ({$completedStatus}, {$cancelledStatus})"; CRM_Core_DAO::executeQuery($sql); + // CRM-12141 + $sql = "ALTER TABLE {$tempTableName2} ADD INDEX index_action (action);"; + CRM_Core_DAO::executeQuery($sql); //handling for completed contribution and cancelled contribution //insertion of new records @@ -771,6 +783,23 @@ AND TABLE_SCHEMA = '{$dbUf['database']}'"; return TRUE; } + /** + * Check/Add INDEX CRM-12141 + * + * @return bool TRUE for success + */ + function task_4_3_x_checkIndexes(CRM_Queue_TaskContext $ctx) { + $query = "SHOW KEYS FROM `civicrm_entity_financial_trxn` +WHERE key_name IN ('UI_entity_financial_trxn_entity_table', 'UI_entity_financial_trxn_entity_id');"; + $dao = CRM_Core_DAO::executeQuery($query); + if (!$dao->N) { + CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_entity_financial_trxn +ADD INDEX UI_entity_financial_trxn_entity_table (entity_table), +ADD INDEX UI_entity_financial_trxn_entity_id (entity_id);"); + } + return TRUE; + } + /** * Update phones CRM-11292 * diff --git a/xml/schema/Financial/EntityFinancialTrxn.xml b/xml/schema/Financial/EntityFinancialTrxn.xml index 1ff8767730..4df5272415 100755 --- a/xml/schema/Financial/EntityFinancialTrxn.xml +++ b/xml/schema/Financial/EntityFinancialTrxn.xml @@ -62,5 +62,15 @@ 3.2 4.3 + + UI_entity_financial_trxn_entity_table + entity_table + 4.3 + + + UI_entity_financial_trxn_entity_id + entity_id + 4.3 + -- 2.25.1