Skip to content

Commit

Permalink
Merge pull request #10169 from seamuslee001/new_indexes
Browse files Browse the repository at this point in the history
CRM-20313,CRM-19357,CRM-20204,CRM-19383
  • Loading branch information
eileenmcnaughton authored Apr 16, 2017
2 parents 8ee7638 + 5b3543c commit afb6f70
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 40 deletions.
18 changes: 17 additions & 1 deletion CRM/Activity/DAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* Generated from xml/schema/CRM/Activity/Activity.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:b54cc88c35882c1870fcfe97d9a529bc)
* (GenCodeChecksum:60fe612216c0096685be3e555a4772c3)
*/
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/Type.php';
Expand Down Expand Up @@ -718,6 +718,22 @@ public static function indices($localize = TRUE) {
'localizable' => false,
'sig' => 'civicrm_activity::0::activity_type_id',
) ,
'index_activity_date_time' => array(
'name' => 'index_activity_date_time',
'field' => array(
0 => 'activity_date_time',
) ,
'localizable' => false,
'sig' => 'civicrm_activity::0::activity_date_time',
) ,
'index_status_id' => array(
'name' => 'index_status_id',
'field' => array(
0 => 'status_id',
) ,
'localizable' => false,
'sig' => 'civicrm_activity::0::status_id',
) ,
'index_medium_id' => array(
'name' => 'index_medium_id',
'field' => array(
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/DAO/AllCoreTables.data.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
// (GenCodeChecksum:2d196ddd274c6e0e1847af66fcc7101d)
// (GenCodeChecksum:4cb264e1d72064f4be4909c4e3ecf3ad)
return array(
'CRM_Core_DAO_AddressFormat' => array(
'name' => 'AddressFormat',
Expand Down
16 changes: 14 additions & 2 deletions CRM/Financial/DAO/EntityFinancialAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* Generated from xml/schema/CRM/Financial/EntityFinancialAccount.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:227febd12437c66f2e3ef5b3689f9901)
* (GenCodeChecksum:b9e9a095e5a6631dd7104828d40ec55a)
*/
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/Type.php';
Expand Down Expand Up @@ -247,7 +247,19 @@ static function &export($prefix = false) {
* Returns the list of indices
*/
public static function indices($localize = TRUE) {
$indices = array();
$indices = array(
'index_entity_id_entity_table_account_relationship' => array(
'name' => 'index_entity_id_entity_table_account_relationship',
'field' => array(
0 => 'entity_id',
1 => 'entity_table',
2 => 'account_relationship',
) ,
'localizable' => false,
'unique' => true,
'sig' => 'civicrm_entity_financial_account::1::entity_id::entity_table::account_relationship',
) ,
);
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}
}
13 changes: 11 additions & 2 deletions CRM/Mailing/Event/DAO/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* Generated from xml/schema/CRM/Mailing/Event/Queue.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:1791a9127131362b0224dd2781085e4a)
* (GenCodeChecksum:61df95ab05407c3c8fcd677a03e32b99)
*/
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/Type.php';
Expand Down Expand Up @@ -247,7 +247,16 @@ static function &export($prefix = false) {
* Returns the list of indices
*/
public static function indices($localize = TRUE) {
$indices = array();
$indices = array(
'index_hash' => array(
'name' => 'index_hash',
'field' => array(
0 => 'hash',
) ,
'localizable' => false,
'sig' => 'civicrm_mailing_event_queue::0::hash',
) ,
);
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}
}
60 changes: 30 additions & 30 deletions sql/civicrm_generated.mysql

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion tests/phpunit/CRM/Financial/BAO/FinancialTypeAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,17 @@ public function createFinancialAccount($financialAccountType, $relationType = NU
'entity_table' => 'civicrm_financial_type',
'entity_id' => $financialType->id,
'account_relationship' => array_search($relationType, $relationTypes),
'financial_account_id' => $financialAccount->id,
);

//CRM-20313: As per unique index added in civicrm_entity_financial_account table,
// first check if there's any record on basis of unique key (entity_table, account_relationship, entity_id)
$dao = new CRM_Financial_DAO_EntityFinancialAccount();
$dao->copyValues($financialParams);
$dao->find();
if ($dao->fetch()) {
$financialParams['id'] = $dao->id;
}
$financialParams['financial_account_id'] = $financialAccount->id;
$financialAccountType = CRM_Financial_BAO_FinancialTypeAccount::add($financialParams);
}
return array($financialAccount, $financialType, $financialAccountType);
Expand Down
14 changes: 12 additions & 2 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3690,10 +3690,20 @@ protected function relationForFinancialTypeWithFinancialAccount($financialTypeId
$account = CRM_Financial_BAO_FinancialAccount::add($params);
$entityParams = array(
'entity_table' => 'civicrm_financial_type',
'account_relationship' => key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' ")),
'entity_id' => $financialTypeId,
'financial_account_id' => $account->id,
'account_relationship' => key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' ")),
);

//CRM-20313: As per unique index added in civicrm_entity_financial_account table,
// first check if there's any record on basis of unique key (entity_table, account_relationship, entity_id)
$dao = new CRM_Financial_DAO_EntityFinancialAccount();
$dao->copyValues($entityParams);
$dao->find();
if ($dao->fetch()) {
$entityParams['id'] = $dao->id;
}
$entityParams['financial_account_id'] = $account->id;

return CRM_Financial_BAO_FinancialTypeAccount::add($entityParams);
}

Expand Down
10 changes: 10 additions & 0 deletions xml/schema/Activity/Activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@
</html>
<add>2.0</add>
</field>
<index>
<name>index_activity_date_time</name>
<fieldName>activity_date_time</fieldName>
<add>4.7</add>
</index>
<field>
<name>due_date_time</name>
<type>datetime</type>
Expand Down Expand Up @@ -248,6 +253,11 @@
<type>Select</type>
</html>
</field>
<index>
<name>index_status_id</name>
<fieldName>status_id</fieldName>
<add>4.7</add>
</index>
<field>
<name>priority_id</name>
<type>int unsigned</type>
Expand Down
9 changes: 8 additions & 1 deletion xml/schema/Financial/EntityFinancialAccount.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,12 @@
<add>4.3</add>
<onDelete>RESTRICT</onDelete>
</foreignKey>
<index>
<name>index_entity_id_entity_table_account_relationship</name>
<fieldName>entity_id</fieldName>
<fieldName>entity_table</fieldName>
<fieldName>account_relationship</fieldName>
<unique>true</unique>
<add>4.7</add>
</index>
</table>

5 changes: 5 additions & 0 deletions xml/schema/Mailing/Event/Queue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
<title>Security Hash</title>
<comment>Security hash</comment>
</field>
<index>
<name>index_hash</name>
<fieldName>hash</fieldName>
<add>4.7</add>
</index>
<field>
<name>phone_id</name>
<type>int unsigned</type>
Expand Down

0 comments on commit afb6f70

Please sign in to comment.