From be400681e721729e11232e808547e002821ba426 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 17 May 2025 00:18:57 +1200 Subject: [PATCH] Fix collection exists fallbacks --- src/Appwrite/Migration/Migration.php | 30 +++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index d7bef9ba93..5199368376 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -204,23 +204,25 @@ abstract class Migration }; if (!$this->dbForProject->getCollection($id)->isEmpty()) { - $collection = $this->collections[$collectionType][$id]; + return; + } - $attributes = []; - foreach ($collection['attributes'] as $attribute) { - $attributes[] = new Document($attribute); - } + $collection = $this->collections[$collectionType][$id]; - $indexes = []; - foreach ($collection['indexes'] as $index) { - $indexes[] = new Document($index); - } + $attributes = []; + foreach ($collection['attributes'] as $attribute) { + $attributes[] = new Document($attribute); + } - try { - $this->dbForProject->createCollection($name, $attributes, $indexes); - } catch (Duplicate ) { - Console::warning('Failed to create collection "' . $name . '": Collection already exists'); - } + $indexes = []; + foreach ($collection['indexes'] as $index) { + $indexes[] = new Document($index); + } + + try { + $this->dbForProject->createCollection($name, $attributes, $indexes); + } catch (Duplicate ) { + Console::warning('Failed to create collection "' . $name . '": Collection already exists'); } }