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'); } }