From 6c8e1a31903206533df5ab5504ec6d627742d8bd Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 5 Jul 2021 09:12:59 +0200 Subject: [PATCH] feat(projects): add version number --- app/config/collections.php | 8 ++++++++ app/controllers/api/projects.php | 1 + src/Appwrite/Migration/Version/V08.php | 7 +++++++ tests/unit/Migration/MigrationV08Test.php | 7 +++++++ 4 files changed, 23 insertions(+) diff --git a/app/config/collections.php b/app/config/collections.php index e6d67f08c3..39b1a03a70 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -779,6 +779,14 @@ $collections = [ 'default' => 0, 'required' => false, ], + [ + '$collection' => Database::SYSTEM_COLLECTION_RULES, + 'label' => 'Version', + 'key' => 'version', + 'type' => Database::SYSTEM_VAR_TYPE_TEXT, + 'default' => '', + 'required' => true, + ], [ '$collection' => Database::SYSTEM_COLLECTION_RULES, 'label' => 'Webhooks', diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 81c4fdab03..2bac0efb85 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -74,6 +74,7 @@ App::post('/v1/projects') 'legalAddress' => $legalAddress, 'legalTaxId' => $legalTaxId, 'teamId' => $team->getId(), + 'version' => APP_VERSION_STABLE, 'platforms' => [], 'webhooks' => [], 'keys' => [], diff --git a/src/Appwrite/Migration/Version/V08.php b/src/Appwrite/Migration/Version/V08.php index 59294c3269..fbc31c4df1 100644 --- a/src/Appwrite/Migration/Version/V08.php +++ b/src/Appwrite/Migration/Version/V08.php @@ -31,6 +31,13 @@ class V08 extends Migration ->removeAttribute('env'); } + break; + /** + * Add version reference to database. + */ + case Database::SYSTEM_COLLECTION_PROJECTS: + $document->setAttribute('version', '0.9.0'); + break; } diff --git a/tests/unit/Migration/MigrationV08Test.php b/tests/unit/Migration/MigrationV08Test.php index cb759cecbd..06ed5f44ff 100644 --- a/tests/unit/Migration/MigrationV08Test.php +++ b/tests/unit/Migration/MigrationV08Test.php @@ -29,5 +29,12 @@ class MigrationV08Test extends MigrationTest $this->assertEquals($document->getAttribute('env', null), null); $this->assertEquals($document->getAttribute('runtime', null), 'node-16'); + + $document = $this->fixDocument(new Document([ + '$id' => 'project', + '$collection' => Database::SYSTEM_COLLECTION_PROJECTS + ])); + + $this->assertEquals($document->getAttribute('version', null), '0.9.0'); } }