From c75b943e2643bb3493bf818f0bdd25cba18ccb4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20Cesar=20Laura=20Avenda=C3=B1o?= Date: Tue, 19 Mar 2019 12:31:29 -0400 Subject: [PATCH] PMC-569 --- workflow/engine/classes/WorkspaceTools.php | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/workflow/engine/classes/WorkspaceTools.php b/workflow/engine/classes/WorkspaceTools.php index bb16c28b9..c1e210b4e 100644 --- a/workflow/engine/classes/WorkspaceTools.php +++ b/workflow/engine/classes/WorkspaceTools.php @@ -4565,4 +4565,30 @@ class WorkspaceTools $stmt->executeQuery($dbInstance->getDropTrigger($triggerName)); } } + + /** + * Delete indexes of specific tables + * + * @param array $tables + */ + public function deleteIndexes($tables) + { + // Get MySQL DB instance class + $database = $this->getDatabase(); + + foreach ($tables as $table) { + // Get all indexes of the table + $indexes = $database->executeQuery($database->generateTableIndexSQL($table)); + $indexesDeleted = []; + foreach ($indexes as $index) { + if ($index['Key_name'] != 'PRIMARY') { + if (!in_array($index['Key_name'], $indexesDeleted)) { + // Remove index + $database->executeQuery($database->generateDropKeySQL($table, $index['Key_name'])); + $indexesDeleted[] = $index['Key_name']; + } + } + } + } + } }