From 3730e33b0c7fca14e9fb1f57f7afcb7f81ded4c9 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 31 Dec 2021 14:40:38 +0100 Subject: [PATCH] fix: api key migration --- src/Appwrite/Migration/Version/V11.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Appwrite/Migration/Version/V11.php b/src/Appwrite/Migration/Version/V11.php index 6a706309e..bf9b7ea10 100644 --- a/src/Appwrite/Migration/Version/V11.php +++ b/src/Appwrite/Migration/Version/V11.php @@ -510,6 +510,29 @@ class V11 extends Migration break; case OldDatabase::SYSTEM_COLLECTION_KEYS: + $projectId = $this->getProjectIdFromReadPermissions($document); + + /** + * Set Project ID + */ + if ($document->getAttribute('projectId') === null) { + $document->setAttribute('projectId', $projectId); + } + + /** + * Set scopes if empty + */ + if (empty($document->getAttribute('scopes', []))) { + $document->setAttribute('scopes', []); + } + + /** + * Reset Permissions + */ + $document->setAttribute('$read', ['role:all']); + $document->setAttribute('$write', ['role:all']); + + break; case OldDatabase::SYSTEM_COLLECTION_WEBHOOKS: $projectId = $this->getProjectIdFromReadPermissions($document);