From 355f1d5e8d3456532fcc534b3188dbc90b80a324 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 25 Dec 2022 15:40:32 +0200 Subject: [PATCH] add internalId to collections --- app/config/collections.php | 11 +++++++++++ app/controllers/api/functions.php | 4 ++-- app/workers/builds.php | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index a37a2b7fb7..722935d77c 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -2111,6 +2111,17 @@ $collections = [ 'array' => false, 'filters' => [], ], + [ + '$id' => ID::custom('deploymentInternalId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => ID::custom('deployment'), 'type' => Database::VAR_STRING, diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index b4bce10b9a..08f470f48b 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -25,7 +25,6 @@ use Appwrite\Task\Validator\Cron; use Appwrite\Utopia\Database\Validator\Queries\Deployments; use Appwrite\Utopia\Database\Validator\Queries\Executions; use Appwrite\Utopia\Database\Validator\Queries\Functions; -use Appwrite\Utopia\Database\Validator\Queries\Variables; use Utopia\App; use Utopia\Database\Database; use Utopia\Database\Document; @@ -33,7 +32,6 @@ use Utopia\Database\DateTime; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; use Utopia\Validator\ArrayList; -use Utopia\Validator\Assoc; use Utopia\Validator\Text; use Utopia\Validator\Range; use Utopia\Validator\WhiteList; @@ -86,6 +84,7 @@ App::post('/v1/functions') 'enabled' => $enabled, 'name' => $name, 'runtime' => $runtime, + 'deploymentInternalId' => '', 'deployment' => '', 'events' => $events, 'schedule' => $schedule, @@ -928,6 +927,7 @@ App::delete('/v1/functions/:functionId/deployments/:deploymentId') if ($function->getAttribute('deployment') === $deployment->getId()) { // Reset function deployment $function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [ + 'deploymentInternalId' => '', 'deployment' => '', ]))); } diff --git a/app/workers/builds.php b/app/workers/builds.php index 3e425c909e..ff7b4402be 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -190,6 +190,7 @@ class BuildsV1 extends Worker /** Set auto deploy */ if ($deployment->getAttribute('activate') === true) { + $function->setAttribute('deploymentInternalId', $deployment->getInternalId()); $function->setAttribute('deployment', $deployment->getId()); $function = $dbForProject->updateDocument('functions', $function->getId(), $function); }