CRM-20367: Add wrapper function for adding and dropping Index in Upgrader
authordeb.monish <monish.deb@jmaconsulting.biz>
Fri, 31 Mar 2017 19:49:27 +0000 (01:19 +0530)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Fri, 31 Mar 2017 19:58:40 +0000 (01:28 +0530)
CRM/Upgrade/Incremental/Base.php

index a0a49c7ffdd95d8913ac3eeb3384a4c5d1bcab0a..22d4adee9644cf76d35024a93d6cdc96c7ddc3a2 100644 (file)
@@ -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;
+  }
+
 }