From 84e9881a6a4638f9253ca409d685442178ce3a39 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Thu, 2 Sep 2021 12:45:03 -0400 Subject: [PATCH 01/15] Delete from attribute/index tables on deleteCollection --- app/controllers/api/database.php | 5 +++++ app/workers/deletes.php | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 7df3172484..191ed38e5f 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -426,6 +426,11 @@ App::delete('/v1/database/collections/:collectionId') throw new Exception('Failed to remove collection from DB', 500); } + $deletes + ->setParam('type', DELETE_TYPE_DOCUMENT) + ->setParam('document', $collection) + ; + $events ->setParam('eventData', $response->output($collection, Response::MODEL_COLLECTION)) ; diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 1894aaf76b..759409d286 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -44,6 +44,9 @@ class DeletesV1 extends Worker switch ($document->getCollection()) { // TODO@kodumbeats define these as constants somewhere + case 'collections': + $this->deleteCollection($document, $projectId); + break; case 'projects': $this->deleteProject($document); break; @@ -88,6 +91,25 @@ class DeletesV1 extends Worker public function shutdown(): void { } + + /** + * @param Document $document teams document + * @param string $projectId + */ + protected function deleteCollection(Document $document, string $projectId): void + { + $collectionId = $document->getId(); + + $dbForInternal = $this->getInternalDB($projectId); + + $this->deleteByGroup('attributes', [ + new Query('collectionId', Query::TYPE_EQUAL, [$collectionId]) + ], $dbForInternal); + + $this->deleteByGroup('indexes', [ + new Query('collectionId', Query::TYPE_EQUAL, [$collectionId]) + ], $dbForInternal); + } /** * @param Document $document teams document From 8c3ca6808c8a1d9c48b095b66f669d53fe91144d Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Thu, 2 Sep 2021 12:46:05 -0400 Subject: [PATCH 02/15] Test deleteCollection removal of attributes/indexes --- tests/e2e/Services/Database/DatabaseCustomServerTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index e5a75fa685..79750318b2 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -403,5 +403,13 @@ class DatabaseCustomServerTest extends Scope $this->assertEquals(400, $tooMany['headers']['status-code']); $this->assertEquals('Index limit exceeded', $tooMany['body']['message']); + + $collection = $this->client->call(Client::METHOD_DELETE, '/database/collections/' . $collectionId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ])); + + $this->assertEquals(204, $collection['headers']['status-code']); } } \ No newline at end of file From bfdf6de15f101ec1cfd62373e646cb0862ab3eb9 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Wed, 15 Sep 2021 14:02:18 -0400 Subject: [PATCH 03/15] Delete collection document from internal collections table --- app/workers/deletes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 78ceeb45a6..f557a3a549 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -112,6 +112,8 @@ class DeletesV1 extends Worker $this->deleteByGroup('indexes', [ new Query('collectionId', Query::TYPE_EQUAL, [$collectionId]) ], $dbForInternal); + + $dbForInternal->deleteDocument('collections', $collectionId); } /** From 43d5d67f4321bd5e33af515228e152ca1e058302 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 16 Sep 2021 10:46:59 +0530 Subject: [PATCH 04/15] feat(tests): check for failing test --- phpunit.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index f0a2813f5a..56885de032 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -19,7 +19,7 @@ ./tests/e2e/Client.php ./tests/e2e/General ./tests/e2e/Scopes - ./tests/e2e/Services/Account + ./tests/e2e/Services/Functions/FunctionsBase.php ./tests/e2e/Services/Functions/FunctionsCustomServerTest.php ./tests/e2e/Services/Functions/FunctionsCustomClientTest.php From f8067b9cfbb72ba2d5368a2daa3c5e9bdee38f79 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 16 Sep 2021 11:08:21 +0530 Subject: [PATCH 05/15] feat(tests): check for failing test --- phpunit.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 56885de032..57e374c80c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -13,14 +13,14 @@ - ./tests/unit/ + - ./tests/e2e/Client.php + + ./tests/e2e/Services/Account + - ./tests/e2e/Services/Functions/FunctionsBase.php + \ No newline at end of file From 3f4a0756ad60c104f6e459285ca6f26dfc3604b7 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 16 Sep 2021 12:36:24 +0530 Subject: [PATCH 06/15] feat(tests): check for failing test --- phpunit.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 57e374c80c..572dceaeea 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -19,10 +19,10 @@ - ./tests/e2e/Services/Account - + ./tests/e2e/Services/Database - ./tests/e2e/Services/Health + - ./tests/e2e/Services/Database - + ./tests/e2e/Services/Health ./tests/e2e/Services/Locale - ./tests/e2e/Services/Projects - ./tests/e2e/Services/Storage - ./tests/e2e/Services/Teams - ./tests/e2e/Services/Users - ./tests/e2e/Services/Workers - ./tests/e2e/Services/Webhooks --> + + + + + + From b580810c7ddef61cd0573cb0b259257a39e6c041 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 16 Sep 2021 13:29:20 +0530 Subject: [PATCH 08/15] feat(tests): check for failing test --- .travis.yml | 3 +++ phpunit.xml | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a90890423c..f5e7ee4681 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ arch: os: linux +vm: + size: x-large + language: shell notifications: diff --git a/phpunit.xml b/phpunit.xml index 44cc631d0e..bd38ab510a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -19,11 +19,11 @@ - + ./tests/e2e/Services/Account - ./tests/e2e/Services/Health - ./tests/e2e/Services/Locale + From cad09af1bdb37c8d31a072ae641b83702f306884 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 16 Sep 2021 13:49:18 +0530 Subject: [PATCH 09/15] feat(tests): check for failing test --- .travis.yml | 2 +- phpunit.xml | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index f5e7ee4681..2fa9ff9357 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ arch: os: linux vm: - size: x-large + size: large language: shell diff --git a/phpunit.xml b/phpunit.xml index bd38ab510a..f0a2813f5a 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -13,26 +13,26 @@ - + ./tests/unit/ - + ./tests/e2e/Scopes ./tests/e2e/Services/Account - - - - - - - - - - + ./tests/e2e/Services/Functions/FunctionsCustomClientTest.php \ No newline at end of file From 086f6312116cb1eea975e36286738b1c4f9ae955 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 16 Sep 2021 17:04:23 +0530 Subject: [PATCH 10/15] feat(tests): check for failing test --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2fa9ff9357..fe7bc3098e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,10 @@ arch: os: linux +# Small change to check build failure vm: - size: large - + size: large + language: shell notifications: From 351b252c2cf2a1aa6e64242c0bc9b8a046f6cad0 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 16 Sep 2021 17:35:53 +0530 Subject: [PATCH 11/15] feat(tests): check for failing test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fe7bc3098e..077c8cc787 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ arch: os: linux -# Small change to check build failure +# Small change to check build vm: size: large From 2853b7f52a5958a293b6877491cc9ad122529d33 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 16 Sep 2021 18:10:18 +0530 Subject: [PATCH 12/15] feat(tests): check for failing test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 077c8cc787..d2f93874b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ arch: os: linux -# Small change to check build +# Small change to check vm: size: large From c03dc64adb8d1c524119abaac5026c75acd50b33 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 16 Sep 2021 18:48:23 +0530 Subject: [PATCH 13/15] feat(tests): check for failing test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d2f93874b5..89dad4bbab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ arch: os: linux -# Small change to check +# Small change to vm: size: large From 13024e97f2ebe8dc244b9f1a0fd20fb4be73ae3f Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 16 Sep 2021 19:27:12 +0530 Subject: [PATCH 14/15] feat(tests): check for failing test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 89dad4bbab..a1a2f6bd65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ arch: os: linux -# Small change to +# Small change vm: size: large From cb7c810207c79eddf8daac344eadc9b8ed4092e4 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Sun, 19 Sep 2021 11:49:24 -0400 Subject: [PATCH 15/15] Drop collection table in deletes worker --- app/controllers/api/database.php | 2 -- app/workers/deletes.php | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index dcef7105ea..26d93ae5be 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -620,8 +620,6 @@ App::delete('/v1/database/collections/:collectionId') throw new Exception('Collection not found', 404); } - $dbForExternal->deleteCollection($collectionId); // TDOD move to DB worker - if (!$dbForInternal->deleteDocument('collections', $collectionId)) { throw new Exception('Failed to remove collection from DB', 500); } diff --git a/app/workers/deletes.php b/app/workers/deletes.php index f557a3a549..8382e14b14 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -104,6 +104,7 @@ class DeletesV1 extends Worker $collectionId = $document->getId(); $dbForInternal = $this->getInternalDB($projectId); + $dbForExternal = $this->getExternalDB($projectId); $this->deleteByGroup('attributes', [ new Query('collectionId', Query::TYPE_EQUAL, [$collectionId]) @@ -113,7 +114,7 @@ class DeletesV1 extends Worker new Query('collectionId', Query::TYPE_EQUAL, [$collectionId]) ], $dbForInternal); - $dbForInternal->deleteDocument('collections', $collectionId); + $dbForExternal->deleteCollection($collectionId); } /**