From f5e9094bdc400adf281256c3b8fcd70312d03f34 Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 15 Jun 2023 09:51:11 +0300 Subject: [PATCH] delete unnecessary project collections task --- Dockerfile | 2 +- bin/delete-project-collections | 3 --- bin/patch-delete-project-collections | 3 +++ src/Appwrite/Platform/Services/Tasks.php | 4 ++-- ...lections.php => PatchDeleteProjectCollections.php} | 11 +++++++---- 5 files changed, 13 insertions(+), 10 deletions(-) delete mode 100644 bin/delete-project-collections create mode 100644 bin/patch-delete-project-collections rename src/Appwrite/Platform/Tasks/{DeleteProjectCollections.php => PatchDeleteProjectCollections.php} (92%) diff --git a/Dockerfile b/Dockerfile index 0239b308d9..f40d6475d1 100755 --- a/Dockerfile +++ b/Dockerfile @@ -121,7 +121,7 @@ RUN chmod +x /usr/local/bin/doctor && \ chmod +x /usr/local/bin/clear-card-cache && \ chmod +x /usr/local/bin/calc-users-stats && \ chmod +x /usr/local/bin/calc-tier-stats && \ - chmod +x /usr/local/bin/delete-project-collections && \ + chmod +x /usr/local/bin/patch-delete-project-collections && \ chmod +x /usr/local/bin/maintenance && \ chmod +x /usr/local/bin/volume-sync && \ chmod +x /usr/local/bin/usage && \ diff --git a/bin/delete-project-collections b/bin/delete-project-collections deleted file mode 100644 index 3991342962..0000000000 --- a/bin/delete-project-collections +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -php /usr/src/code/app/cli.php delete-project-collections $@ \ No newline at end of file diff --git a/bin/patch-delete-project-collections b/bin/patch-delete-project-collections new file mode 100644 index 0000000000..8bf0736cf3 --- /dev/null +++ b/bin/patch-delete-project-collections @@ -0,0 +1,3 @@ +#!/bin/sh + +php /usr/src/code/app/cli.php patch-delete-project-collections $@ \ No newline at end of file diff --git a/src/Appwrite/Platform/Services/Tasks.php b/src/Appwrite/Platform/Services/Tasks.php index fc40049f7c..10c573da42 100644 --- a/src/Appwrite/Platform/Services/Tasks.php +++ b/src/Appwrite/Platform/Services/Tasks.php @@ -21,7 +21,7 @@ use Appwrite\Platform\Tasks\Version; use Appwrite\Platform\Tasks\VolumeSync; use Appwrite\Platform\Tasks\CalcUsersStats; use Appwrite\Platform\Tasks\CalcTierStats; -use Appwrite\Platform\Tasks\DeleteProjectCollections; +use Appwrite\Platform\Tasks\PatchDeleteProjectCollections; class Tasks extends Service { @@ -47,7 +47,7 @@ class Tasks extends Service ->addAction(Specs::getName(), new Specs()) ->addAction(CalcUsersStats::getName(), new CalcUsersStats()) ->addAction(CalcTierStats::getName(), new CalcTierStats()) - ->addAction(DeleteProjectCollections::getName(), new DeleteProjectCollections()) + ->addAction(PatchDeleteProjectCollections::getName(), new PatchDeleteProjectCollections()) ; } } diff --git a/src/Appwrite/Platform/Tasks/DeleteProjectCollections.php b/src/Appwrite/Platform/Tasks/PatchDeleteProjectCollections.php similarity index 92% rename from src/Appwrite/Platform/Tasks/DeleteProjectCollections.php rename to src/Appwrite/Platform/Tasks/PatchDeleteProjectCollections.php index db9c28eefb..ac8e48b3ae 100644 --- a/src/Appwrite/Platform/Tasks/DeleteProjectCollections.php +++ b/src/Appwrite/Platform/Tasks/PatchDeleteProjectCollections.php @@ -11,7 +11,7 @@ use Utopia\Database\Query; use Utopia\Pools\Group; use Utopia\Registry\Registry; -class DeleteProjectCollections extends Action +class PatchDeleteProjectCollections extends Action { private array $names = [ 'webhooks', @@ -26,7 +26,7 @@ class DeleteProjectCollections extends Action public static function getName(): string { - return 'delete-project-collections'; + return 'patch-delete-project-collections'; } public function __construct() @@ -45,10 +45,10 @@ class DeleteProjectCollections extends Action public function action(Group $pools, Cache $cache, Database $dbForConsole, Registry $register): void { - //docker compose exec -t appwrite delete-project-collections + //docker compose exec -t appwrite patch-delete-project-collections Console::title('Delete project collections V1'); - Console::success(APP_NAME . ' delete project collections'); + Console::success(APP_NAME . ' delete project collections has started'); /* Initialise new Utopia app */ $app = new App('UTC'); @@ -87,6 +87,9 @@ class DeleteProjectCollections extends Action $dbForProject->setNamespace('_' . $project->getInternalId()); foreach ($this->names as $name) { + if (empty($name)) { + continue; + } if ($dbForProject->exists('appwrite', $name)) { if ($dbForProject->deleteCollection($name)) { Console::log('Deleted ' . $name);