mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 08:58:35 +00:00
delete unnecessary project collections task
This commit is contained in:
parent
579a95aecc
commit
f5e9094bdc
5 changed files with 13 additions and 10 deletions
|
|
@ -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 && \
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
php /usr/src/code/app/cli.php delete-project-collections $@
|
||||
3
bin/patch-delete-project-collections
Normal file
3
bin/patch-delete-project-collections
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
php /usr/src/code/app/cli.php patch-delete-project-collections $@
|
||||
|
|
@ -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())
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
Loading…
Reference in a new issue