From aac46cd5fe13867d4c1bf8fbb77e71def31b53a6 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 6 Sep 2023 19:59:42 +0000 Subject: [PATCH] fix: migration issues --- CHANGES.md | 9 ++++----- src/Appwrite/Migration/Version/V19.php | 27 +++++++++++++------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 84448c7685..f7ebdb358d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,8 +4,8 @@ ## Changes -* 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 +- 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 @@ -15,12 +15,11 @@ * 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 +* Support for v2 functions [#6142](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: Global variables by [#6150](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 896fc816a8..418fd68d85 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -651,7 +651,7 @@ class V19 extends Migration switch ($document->getCollection()) { case 'attributes': case 'indexes': - $status = $document->getAttribute('status', ''); + $status = $document->getAttribute('status', $document->getAttribute('status', '')); if ($status === 'failed') { $document->setAttribute('error', 'Unknown problem'); } @@ -663,10 +663,10 @@ class V19 extends Migration $stdout = $document->getAttribute('stdout', ''); $stderr = $document->getAttribute('stderr', ''); - $document->setAttribute('logs', $stdout . PHP_EOL . $stderr); + $document->setAttribute('logs', $document->getAttribute('logs', $stdout . PHP_EOL . $stderr)); break; case 'databases': - $document->setAttribute('enabled', true); + $document->setAttribute('enabled', $document->getAttribute('enabled', true)); break; case 'deployments': $resourceId = $document->getAttribute('resourceId'); @@ -680,9 +680,8 @@ class V19 extends Migration } $commands = $this->getFunctionCommands($function); - $document->setAttribute('commands', $commands); - - $document->setAttribute('type', 'manual'); + $document->setAttribute('commands', $document->getAttribute('commands', $commands)); + $document->setAttribute('type', $document->getAttribute('type', 'manual')); break; case 'executions': $functionId = $document->getAttribute('functionId'); @@ -694,9 +693,9 @@ class V19 extends Migration $document->setAttribute('deploymentInternalId', $deployment->getInternalId()); break; case 'functions': - $document->setAttribute('live', true); - $document->setAttribute('logging', true); - $document->setAttribute('version', 'v2'); + $document->setAttribute('live', $document->getAttribute('live', true)); + $document->setAttribute('logging', $document->getAttribute('logging', true)); + $document->setAttribute('version', $document->getAttribute('version', 'v2')); $deploymentId = $document->getAttribute('deployment'); if (!empty($deploymentId)) { @@ -706,7 +705,7 @@ class V19 extends Migration } $commands = $this->getFunctionCommands($document); - $document->setAttribute('commands', $commands); + $document->setAttribute('commands', $document->getAttribute('commands', $commands)); $schedule = $this->consoleDB->createDocument('schedules', new Document([ 'region' => App::getEnv('_APP_REGION', 'default'), // Todo replace with projects region @@ -728,13 +727,13 @@ class V19 extends Migration $databases = Config::getParam('pools-database', []); $database = $databases[0]; - $document->setAttribute('database', $database); - $document->setAttribute('smtp', []); - $document->setAttribute('templates', []); + $document->setAttribute('database', $document->getAttribute('live', $database)); + $document->setAttribute('smtp', $document->getAttribute('smtp', [])); + $document->setAttribute('templates', $document->getAttribute('templates', [])); break; case 'variables': - $document->setAttribute('resourceType', 'function'); + $document->setAttribute('resourceType', $document->getAttribute('resourceType', 'function')); break; default: break;