From 441156da7c7a7832d4e67efa99664a500ee49772 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 15 Oct 2021 18:11:20 +0200 Subject: [PATCH] chore(release): prepare 0.11.0 release --- README.md | 6 +-- app/init.php | 5 +-- src/Appwrite/Migration/Migration.php | 13 +++--- src/Appwrite/Migration/Version/V10.php | 48 +++++++++++++++++++++++ tests/unit/Migration/MigrationV10Test.php | 31 +++++++++++++++ 5 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 src/Appwrite/Migration/Version/V10.php create mode 100644 tests/unit/Migration/MigrationV10Test.php diff --git a/README.md b/README.md index d838289f8..34b14ee7f 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ docker run -it --rm \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \ --entrypoint="install" \ - appwrite/appwrite:0.10.4 + appwrite/appwrite:0.11.0 ``` ### Windows @@ -70,7 +70,7 @@ docker run -it --rm ^ --volume //var/run/docker.sock:/var/run/docker.sock ^ --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^ --entrypoint="install" ^ - appwrite/appwrite:0.10.4 + appwrite/appwrite:0.11.0 ``` #### PowerShell @@ -80,7 +80,7 @@ docker run -it --rm , --volume /var/run/docker.sock:/var/run/docker.sock , --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw , --entrypoint="install" , - appwrite/appwrite:0.10.4 + appwrite/appwrite:0.11.0 ``` Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please note that on non-linux native hosts, the server might take a few minutes to start after installation completes. diff --git a/app/init.php b/app/init.php index be6803172..c0d98a588 100644 --- a/app/init.php +++ b/app/init.php @@ -26,7 +26,6 @@ use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Database\Document; use Appwrite\Database\Validator\Authorization; use Appwrite\Event\Event; -use Appwrite\Event\Realtime; use Appwrite\OpenSSL\OpenSSL; use Utopia\App; use Utopia\View; @@ -48,8 +47,8 @@ const APP_USERAGENT = APP_NAME.'-Server v%s. Please report abuse at %s'; const APP_MODE_DEFAULT = 'default'; const APP_MODE_ADMIN = 'admin'; const APP_PAGING_LIMIT = 12; -const APP_CACHE_BUSTER = 160; -const APP_VERSION_STABLE = '0.10.4'; +const APP_CACHE_BUSTER = 170; +const APP_VERSION_STABLE = '0.11.0'; const APP_STORAGE_UPLOADS = '/storage/uploads'; const APP_STORAGE_FUNCTIONS = '/storage/functions'; const APP_STORAGE_CACHE = '/storage/cache'; diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 2ab1ce4fd..5c9bda18e 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -48,6 +48,7 @@ abstract class Migration '0.10.2' => 'V09', '0.10.3' => 'V09', '0.10.4' => 'V09', + '0.10.0' => 'V10', ]; /** @@ -102,7 +103,9 @@ abstract class Migration foreach ($all as $document) { go(function () use ($document, $callback) { if (empty($document->getId()) || empty($document->getCollection())) { - Console::warning('Skipped Document due to missing ID or Collection.'); + if ($document->getCollection() !== 0) { + Console::warning('Skipped Document due to missing ID or Collection.'); + } return; } @@ -133,7 +136,7 @@ abstract class Migration public function check_diff_multi($array1, $array2){ $result = array(); - + foreach($array1 as $key => $val) { if(is_array($val) && isset($array2[$key])) { $tmp = $this->check_diff_multi($val, $array2[$key]); @@ -147,14 +150,14 @@ abstract class Migration elseif($val !== $array2[$key]) { $result[$key] = $array2[$key]; } - + if(isset($array2[$key])) { unset($array2[$key]); } } - + $result = array_merge($result, $array2); - + return $result; } diff --git a/src/Appwrite/Migration/Version/V10.php b/src/Appwrite/Migration/Version/V10.php new file mode 100644 index 000000000..0760e3ff9 --- /dev/null +++ b/src/Appwrite/Migration/Version/V10.php @@ -0,0 +1,48 @@ +project; + Console::log('Migrating project: ' . $project->getAttribute('name') . ' (' . $project->getId() . ')'); + + $this->forEachDocument([$this, 'fixDocument']); + } + + protected function fixDocument(Document $document) + { + switch ($document->getAttribute('$collection')) { + /** + * Add version reference to database. + */ + case Database::SYSTEM_COLLECTION_PROJECTS: + $document->setAttribute('version', '0.11.0'); + + break; + } + + foreach ($document as &$attr) { + if ($attr instanceof Document) { + $attr = $this->fixDocument($attr); + } + + if (\is_array($attr)) { + foreach ($attr as &$child) { + if ($child instanceof Document) { + $child = $this->fixDocument($child); + } + } + } + } + + return $document; + } +} diff --git a/tests/unit/Migration/MigrationV10Test.php b/tests/unit/Migration/MigrationV10Test.php new file mode 100644 index 000000000..6aeacb5c7 --- /dev/null +++ b/tests/unit/Migration/MigrationV10Test.php @@ -0,0 +1,31 @@ +pdo = new \PDO('sqlite::memory:'); + $this->migration = new V10($this->pdo); + $reflector = new ReflectionClass('Appwrite\Migration\Version\V10'); + $this->method = $reflector->getMethod('fixDocument'); + $this->method->setAccessible(true); + } + + public function testMigration() + { + $document = $this->fixDocument(new Document([ + '$id' => 'project', + '$collection' => Database::SYSTEM_COLLECTION_PROJECTS, + 'version' => '0.10.0' + ])); + + $this->assertEquals($document->getAttribute('version', '0.10.0'), '0.110'); + } +}