From 5cfabc7a12abb9b2037f64d5eab69f812acbb065 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 6 Sep 2023 19:25:07 +0000 Subject: [PATCH] fix: migrations fix and update changelog --- CHANGES.md | 18 +++++++- src/Appwrite/Migration/Version/V19.php | 60 +++++++++++++------------- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6441a6e438..84448c7685 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,23 @@ ## Changes -- Make installation confirmation case insensitive [#6097](https://github.com/appwrite/appwrite/pull/6097) +* Fix create phone session abuse key by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6134 +* Fix CLI backwards compatibility by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6125 +* Override forEachDocument() to skip the cache collection by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6144 +* Fix Not Found error when deploying function from git by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6133 +* Add required params for scheduled functions by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6148 +* Update the error message for router_domain_not_configured by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6145 +* Fix _APP_EXECUTOR_HOST for upgrades by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6141 +* Change executor hostname back to appwrite-executor by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6160 +* Fix create execution request filter from previous SDK version by @stnguyen90 in https://github.com/appwrite/appwrite/pull/6146 +* Fix: AI Assistant by @Meldiron in https://github.com/appwrite/appwrite/pull/6153 +* Make URL optional for Create Membership API and Serverside Requests by @PineappleIOnic in https://github.com/appwrite/appwrite/pull/6157 +* Fix: v2 functions by @Meldiron in https://github.com/appwrite/appwrite/pull/6142 +* Fix migrations worker by @abnegate in https://github.com/appwrite/appwrite/pull/6116 +* Fix: Global variables by @Meldiron in https://github.com/appwrite/appwrite/pull/6150 +* Fix webhook secret validation and executor path validation by @vermakhushboo in https://github.com/appwrite/appwrite/pull/6162 +* Fix: Untrusted custom domains + auto-ssl by @Meldiron in https://github.com/appwrite/appwrite/pull/6155 +* Update composer.lock by @PineappleIOnic in https://github.com/appwrite/appwrite/pull/6161 # Version 1.4.1 diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php index 601f122ad9..896fc816a8 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -50,35 +50,37 @@ class V19 extends Migration protected function migrateDomains(): void { - foreach ($this->documentsIterator('domains') as $domain) { - $status = 'created'; - if ($domain->getAttribute('verification', false)) { - $status = 'verified'; - } - - $projectId = $domain->getAttribute('projectId'); - $projectInternalId = $domain->getAttribute('projectInternalId'); - - if (empty($projectId) || empty($projectInternalId)) { - Console::warning("Error migrating domain {$domain->getAttribute('domain')}: Missing projectId or projectInternalId"); - continue; - } - - $ruleDocument = new Document([ - 'projectId' => $domain->getAttribute('projectId'), - 'projectInternalId' => $domain->getAttribute('projectInternalId'), - 'domain' => $domain->getAttribute('domain'), - 'resourceType' => 'api', - 'resourceInternalId' => '', - 'resourceId' => '', - 'status' => $status, - 'certificateId' => $domain->getAttribute('certificateId'), - ]); - - try { - $this->consoleDB->createDocument('rules', $ruleDocument); - } catch (\Throwable $th) { - Console::warning("Error migrating domain {$domain->getAttribute('domain')}: {$th->getMessage()}"); + if ($this->consoleDB->exists($this->consoleDB->getDefaultDatabase(), 'domains')) { + foreach ($this->documentsIterator('domains') as $domain) { + $status = 'created'; + if ($domain->getAttribute('verification', false)) { + $status = 'verified'; + } + + $projectId = $domain->getAttribute('projectId'); + $projectInternalId = $domain->getAttribute('projectInternalId'); + + if (empty($projectId) || empty($projectInternalId)) { + Console::warning("Error migrating domain {$domain->getAttribute('domain')}: Missing projectId or projectInternalId"); + continue; + } + + $ruleDocument = new Document([ + 'projectId' => $domain->getAttribute('projectId'), + 'projectInternalId' => $domain->getAttribute('projectInternalId'), + 'domain' => $domain->getAttribute('domain'), + 'resourceType' => 'api', + 'resourceInternalId' => '', + 'resourceId' => '', + 'status' => $status, + 'certificateId' => $domain->getAttribute('certificateId'), + ]); + + try { + $this->consoleDB->createDocument('rules', $ruleDocument); + } catch (\Throwable $th) { + Console::warning("Error migrating domain {$domain->getAttribute('domain')}: {$th->getMessage()}"); + } } } }