From d36e5b0167ff83f8986f9f2a69c19d185aa7d7b7 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 27 Jun 2022 13:46:32 +0200 Subject: [PATCH] fix: migration speed --- src/Appwrite/Migration/Version/V14.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Migration/Version/V14.php b/src/Appwrite/Migration/Version/V14.php index 7704e462d2..fdffc9823e 100644 --- a/src/Appwrite/Migration/Version/V14.php +++ b/src/Appwrite/Migration/Version/V14.php @@ -5,6 +5,7 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; use Utopia\App; use Utopia\CLI\Console; +use Utopia\Database\Database; use Utopia\Database\Document; class V14 extends Migration @@ -19,6 +20,13 @@ class V14 extends Migration global $register; $this->pdo = $register->get('db'); + /** + * Disable SubQueries for Speed. + */ + foreach (['subQueryAttributes', 'subQueryIndexes', 'subQueryPlatforms', 'subQueryDomains', 'subQueryKeys', 'subQueryWebhooks', 'subQuerySessions', 'subQueryTokens', 'subQueryMemberships'] as $name) { + Database::addFilter($name, fn () => null, fn () => []); + } + Console::log('Migrating project: ' . $this->project->getAttribute('name') . ' (' . $this->project->getId() . ')'); Console::info('Migrating Collections'); $this->migrateCollections(); @@ -40,10 +48,15 @@ class V14 extends Migration */ public function createDatabaseLayer(): void { - if (!$this->projectDB->exists('databases')) { - $this->createCollection('databases'); + try { + if (!$this->projectDB->exists('databases')) { + $this->createCollection('databases'); + } + } catch (\Throwable $th) { + Console::warning($th->getMessage()); } + if ($this->project->getId() === 'console') { return; } @@ -649,7 +662,7 @@ class V14 extends Migration if (is_null($document->getAttribute('phoneVerification'))) { $document->setAttribute('phoneVerification', false); } - + var_dump($document->getArrayCopy()); break; case 'functions': /**