delete unnecessary project collections task

This commit is contained in:
shimon 2023-06-15 09:51:11 +03:00
parent 579a95aecc
commit f5e9094bdc
5 changed files with 13 additions and 10 deletions

View file

@ -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 && \

View file

@ -1,3 +0,0 @@
#!/bin/sh
php /usr/src/code/app/cli.php delete-project-collections $@

View file

@ -0,0 +1,3 @@
#!/bin/sh
php /usr/src/code/app/cli.php patch-delete-project-collections $@

View file

@ -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())
;
}
}

View file

@ -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);