$this->addTask('Add Index to civicrm_contribution creditnote_id field', 'addIndexContributionCreditNoteID');
}
+ /**
+ * Upgrade function.
+ *
+ * @param string $rev
+ */
+ public function upgrade_4_7_2($rev) {
+ $this->addTask('Fix Index on civicrm_financial_item combined entity_id + entity_table', 'addCombinedIndexFinancialItemEntityIDEntityType');
+ }
+
/**
* CRM-16354
*
return TRUE;
}
+ /**
+ * CRM-17775 Add correct index for table civicrm_financial_item.
+ *
+ * Note that the entity ID should always precede the entity_table as
+ * it is more unique. This is better for performance and does not cause fallback
+ * to no index if table it omitted.
+ *
+ * @return bool
+ */
+ public function addCombinedIndexFinancialItemEntityIDEntityType() {
+ CRM_Core_BAO_SchemaHandler::dropIndexIfExists('civicrm_financial_item', 'UI_id');
+ CRM_Core_BAO_SchemaHandler::dropIndexIfExists('civicrm_financial_item', 'IX_Entity');
+ CRM_Core_BAO_SchemaHandler::createIndexes(array(
+ 'civicrm_financial_item' => array(array('entity_id', 'entity_table')),
+ ));
+ return TRUE;
+ }
+
}
<fieldName>id</fieldName>
<unique>true</unique>
<add>4.3</add>
+ <drop>4.7</drop>
</index>
<index>
<name>IX_created_date</name>
<fieldName>entity_table</fieldName>
<fieldName>entity_id</fieldName>
<add>4.3</add>
+ <drop>4.7</drop>
</index>
<index>
- <name>IX_entity</name>
- <fieldName>entity_table</fieldName>
+ <name>index_entity_id_entity_table</name>
<fieldName>entity_id</fieldName>
- <add>4.3</add>
+ <fieldName>entity_table</fieldName>
+ <add>4.7</add>
</index>
</table>