<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
+ | CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2017
+ * @copyright CiviCRM LLC (c) 2004-2018
*/
/**
//create index only for searchable fields during ADD,
//create index only if field is become searchable during MODIFY,
- //drop index only if field is no more searchable and index was exist.
+ //drop index only if field is no longer searchable and it does not reference
+ //a forgein key (and indexExist is true)
if (!empty($params['searchable']) && !$indexExist) {
$sql .= $separator;
$sql .= str_repeat(' ', 8);
$sql .= $prefix;
$sql .= "INDEX_{$params['name']} ( {$params['name']} )";
}
- elseif (empty($params['searchable']) && $indexExist) {
+ elseif (empty($params['searchable']) && empty($params['fk_table_name']) && $indexExist) {
$sql .= $separator;
$sql .= str_repeat(' ', 8);
$sql .= "DROP INDEX INDEX_{$params['name']}";