From 19415e64fd9891d7d19c0cf1fa254502b0f0e773 Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Sat, 1 Apr 2017 01:19:27 +0530 Subject: [PATCH] CRM-20367: Add wrapper function for adding and dropping Index in Upgrader --- CRM/Upgrade/Incremental/Base.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CRM/Upgrade/Incremental/Base.php b/CRM/Upgrade/Incremental/Base.php index a0a49c7ffd..22d4adee96 100644 --- a/CRM/Upgrade/Incremental/Base.php +++ b/CRM/Upgrade/Incremental/Base.php @@ -165,4 +165,33 @@ class CRM_Upgrade_Incremental_Base { return TRUE; } + /** + * Add a index to a table column. + * + * @param CRM_Queue_TaskContext $ctx + * @param string $table + * @param string $column + * @return bool + */ + public static function addIndex($ctx, $table, $column) { + $tables = array($table => array($column)); + CRM_Core_BAO_SchemaHandler::createIndexes($tables); + + return TRUE; + } + + /** + * Drop a index from a table if it exist. + * + * @param CRM_Queue_TaskContext $ctx + * @param string $table + * @param string $indexName + * @return bool + */ + public static function dropIndex($ctx, $table, $indexName) { + CRM_Core_BAO_SchemaHandler::dropIndexIfExists($table, $indexName); + + return TRUE; + } + } -- 2.25.1