From 129653a6d6307559ccc72d6ebf439f7ef1863762 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 24 Jun 2022 18:46:13 +0200 Subject: [PATCH] fix: migrate databaseId --- src/Appwrite/Migration/Version/V14.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Migration/Version/V14.php b/src/Appwrite/Migration/Version/V14.php index 4cdac772ac..160843439e 100644 --- a/src/Appwrite/Migration/Version/V14.php +++ b/src/Appwrite/Migration/Version/V14.php @@ -130,6 +130,11 @@ class V14 extends Migration } try { + /** + * Add Database ID for Collections. + */ + $this->createAttributeFromCollection($this->projectDB, 'database_1', 'databaseId', 'collections'); + /** * Add Database Internal ID for Collections. */ @@ -175,7 +180,9 @@ class V14 extends Migration WHERE _uid = 'collection_{$internalId}'; ")->execute(); - $collection->setAttribute('databaseInternalId', '1'); + $collection + ->setAttribute('databaseId', 'default') + ->setAttribute('databaseInternalId', '1'); $this->projectDB->updateDocument('database_1', $collection->getId(), $collection); } catch (\Throwable $th) { Console::warning($th->getMessage()); @@ -211,6 +218,14 @@ class V14 extends Migration switch ($id) { case 'attributes': case 'indexes': + try { + /** + * Create 'databaseInternalId' attribute + */ + $this->createAttributeFromCollection($this->projectDB, $id, 'databaseId'); + } catch (\Throwable $th) { + Console::warning("'databaseInternalId' from {$id}: {$th->getMessage()}"); + } try { /** * Create 'databaseInternalId' attribute @@ -555,11 +570,17 @@ class V14 extends Migration $document->setAttribute('collectionInternalId', $internalId); } /** - * Add Internal ID 'collectionId' for Subqueries. + * Add Internal ID 'databaseInternalId' for Subqueries. */ if (is_null($document->getAttribute('databaseInternalId'))) { $document->setAttribute('databaseInternalId', '1'); } + /** + * Add Internal ID 'databaseInternalId' for Subqueries. + */ + if (is_null($document->getAttribute('databaseId'))) { + $document->setAttribute('databaseId', 'default'); + } try { /**