From 2d0ace7cd534f267e6d1e52e6f8aa0c9b3f5ec96 Mon Sep 17 00:00:00 2001 From: eldadfux Date: Thu, 22 Aug 2019 23:42:06 +0300 Subject: [PATCH] Added method to delete complete namespace --- src/Database/Adapter/MySQL.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Database/Adapter/MySQL.php b/src/Database/Adapter/MySQL.php index 66cce913d2..b193af6501 100644 --- a/src/Database/Adapter/MySQL.php +++ b/src/Database/Adapter/MySQL.php @@ -404,6 +404,39 @@ class MySQL extends Adapter return true; } + /** + * Delete Namespace + * + * @param $namespace + * @throws Exception + * @return bool + */ + public function deleteNamespace($namespace) + { + if(empty($namespace)) { + throw new Exception('Empty namespace'); + } + + $documents = 'app_' . $namespace . '.database.documents'; + $properties = 'app_' . $namespace . '.database.properties'; + $relationships = 'app_' . $namespace . '.database.relationships'; + $audit = 'app_' . $namespace . '.audit.audit'; + $abuse = 'app_' . $namespace . '.abuse.abuse'; + + try { + $this->getPDO()->prepare('DROP TABLE `' . $documents . '`;')->execute(); + $this->getPDO()->prepare('DROP TABLE `' . $properties . '`;')->execute(); + $this->getPDO()->prepare('DROP TABLE `' . $relationships . '`;')->execute(); + $this->getPDO()->prepare('DROP TABLE `' . $audit .'`;')->execute(); + $this->getPDO()->prepare('DROP TABLE `' . $abuse . '`;')->execute(); + } + catch (Exception $e) { + throw $e; + } + + return true; + } + /** * Get Collection *