From 5542e5b04c628827094f662dd922ab0ee7e192df Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Tue, 11 Oct 2022 22:49:59 +0000 Subject: [PATCH 1/2] Only delete collection data for correct db Ensure attributes, indexes, and audit for correct database is deleted. --- app/workers/deletes.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 19ab56c69a..b015043b1d 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -193,21 +193,24 @@ class DeletesV1 extends Worker protected function deleteCollection(Document $document, string $projectId): void { $collectionId = $document->getId(); - $databaseId = str_replace('database_', '', $document->getCollection()); + $databaseId = $document->getAttribute('databaseId'); + $databaseInternalId = $document->getAttribute('databaseInternalId'); $dbForProject = $this->getProjectDB($projectId); - $dbForProject->deleteCollection('database_' . $databaseId . '_collection_' . $document->getInternalId()); + $dbForProject->deleteCollection('database_' . $databaseInternalId . '_collection_' . $document->getInternalId()); $this->deleteByGroup('attributes', [ + Query::equal('databaseId', [$databaseId]), Query::equal('collectionId', [$collectionId]) ], $dbForProject); $this->deleteByGroup('indexes', [ + Query::equal('databaseId', [$databaseId]), Query::equal('collectionId', [$collectionId]) ], $dbForProject); - $this->deleteAuditLogsByResource('collection/' . $collectionId, $projectId); + $this->deleteAuditLogsByResource('database/' . $databaseId . '/collection/' . $collectionId, $projectId); } /** From 99abb200d64e4e9c809e9be28abddd16e1fe0073 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Tue, 11 Oct 2022 22:56:55 +0000 Subject: [PATCH 2/2] Update CHANGES.md --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index df303e8555..60c6c71179 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +# Version 1.0.3 +## Bugs +- Fix document audit deletion [#4429](https://github.com/appwrite/appwrite/pull/4429) +- Fix attribute, index, and audit deletion [#4429](https://github.com/appwrite/appwrite/pull/4429) + # Version 1.0.2 ## Bugs - Fixed nullable values in functions variables [#3885](https://github.com/appwrite/appwrite/pull/3885)