From d63c429d3e3bd9e159d7f6665a70ed9314a5751a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 27 Dec 2022 08:35:55 +0100 Subject: [PATCH] Implement 1.2 migration --- src/Appwrite/Migration/Version/V17.php | 29 ++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Migration/Version/V17.php b/src/Appwrite/Migration/Version/V17.php index 66a02662d1..5b49b961eb 100644 --- a/src/Appwrite/Migration/Version/V17.php +++ b/src/Appwrite/Migration/Version/V17.php @@ -2,6 +2,7 @@ namespace Appwrite\Migration\Version; +use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; use Utopia\CLI\Console; use Utopia\Database\Database; @@ -27,8 +28,8 @@ class V17 extends Migration Console::info('Migrating Collections'); $this->migrateCollections(); - // Console::info('Migrating Documents'); - // $this->forEachDocument([$this, 'fixDocument']); + Console::info('Migrating Documents'); + $this->forEachDocument([$this, 'fixDocument']); } /** @@ -75,6 +76,30 @@ class V17 extends Migration */ protected function fixDocument(Document $document) { + switch ($document->getCollection()) { + case 'projects': + /** + * Bump version number. + */ + $document->setAttribute('version', '1.1.0'); + + /** + * Set default maxSessions + */ + $document->setAttribute('auths', array_merge($document->getAttribute('auths', []), [ + 'maxSessions' => APP_LIMIT_USER_SESSIONS_DEFAULT + ])); + break; + case 'users': + /** + * Set hashOptions type + */ + $document->setAttribute('hashOptions', array_merge($document->getAttribute('hashOptions', []), [ + 'type' => $document->getAttribute('hash', Auth::DEFAULT_ALGO) + ])); + break; + } + return $document; } }