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 1/3] 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; } } From a922f7f0e1a58272238bb478f5d7d3481746f160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 27 Dec 2022 09:15:05 +0100 Subject: [PATCH 2/3] Fix test --- tests/unit/Docker/EnvTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/Docker/EnvTest.php b/tests/unit/Docker/EnvTest.php index 6730491438..e6c9b8cadf 100644 --- a/tests/unit/Docker/EnvTest.php +++ b/tests/unit/Docker/EnvTest.php @@ -37,6 +37,7 @@ class EnvTest extends TestCase $this->assertEquals("_APP_X=value1 _APP_Y=value2 _APP_Z=value3 +_APP_W=value5= ", $this->object->export()); } } From 7532309bbb09ba43fb757649a7aa039c8fa90404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 27 Dec 2022 10:31:49 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- src/Appwrite/Migration/Version/V17.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Migration/Version/V17.php b/src/Appwrite/Migration/Version/V17.php index 5b49b961eb..27ece55107 100644 --- a/src/Appwrite/Migration/Version/V17.php +++ b/src/Appwrite/Migration/Version/V17.php @@ -81,7 +81,7 @@ class V17 extends Migration /** * Bump version number. */ - $document->setAttribute('version', '1.1.0'); + $document->setAttribute('version', '1.2.0'); /** * Set default maxSessions