From 6ddb62badfaa675b5cbe9c36d0b7ad0277f9a049 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 15 Sep 2026 09:42:10 +0000 Subject: [PATCH] fix(executions): stop creating MySQL collection Remove the project-database executions schema now that ClickHouse is the only execution store. Keep execution and site-log query validation independent from the physical MySQL collection definition. Co-authored-by: Torsten Dittmann --- app/config/collections/projects.php | 271 ------------------ .../Database/Validator/Queries/Base.php | 22 +- .../Database/Validator/Queries/Executions.php | 14 +- .../Database/Validator/Queries/Logs.php | 2 +- tests/unit/General/CollectionsTest.php | 18 ++ 5 files changed, 44 insertions(+), 283 deletions(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index 459772d10a..8d5c27060f 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -2012,277 +2012,6 @@ return [ ], ], - 'executions' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('executions'), - 'name' => 'Executions', - 'attributes' => [ - [ - '$id' => ID::custom('resourceInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('resourceType'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - '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('deploymentId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('trigger'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - '$id' => ID::custom('status'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('duration'), - 'type' => Database::VAR_FLOAT, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('errors'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => APP_FUNCTION_ERROR_LENGTH_LIMIT, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('logs'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => APP_FUNCTION_LOG_LENGTH_LIMIT, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('requestMethod'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 128, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - 'array' => false, - '$id' => ID::custom('requestPath'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2048, - 'signed' => true, - 'required' => false, - 'default' => null, - 'filters' => [], - ], - [ - '$id' => ID::custom('requestHeaders'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('responseStatusCode'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('responseHeaders'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('scheduledAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('scheduleInternalId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('scheduleId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => ID::custom('_key_resource'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceInternalId', 'resourceType', 'resourceId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_trigger'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['trigger'], - 'lengths' => [32], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_status'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['status'], - 'lengths' => [32], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_requestMethod'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['requestMethod'], - 'lengths' => [128], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_requestPath'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['requestPath'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_deployment'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['deploymentId'], - 'lengths' => [Database::LENGTH_KEY], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_responseStatusCode'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['responseStatusCode'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_duration'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['duration'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_resourceType'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['resourceType'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - ], - ], - 'variables' => [ '$collection' => Database::METADATA, '$id' => 'variables', diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php index 688a67a20d..056eb467b4 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -18,22 +18,24 @@ class Base extends Queries /** * Expression constructor * - * @param string $collection + * @param string|array $collection * @param string[] $allowedAttributes * @throws \Exception */ - public function __construct(string $collection, array $allowedAttributes) + public function __construct(string|array $collection, array $allowedAttributes) { - $config = Config::getParam('collections', []); + if (\is_string($collection)) { + $config = Config::getParam('collections', []); - $collections = \array_merge( - $config['projects'], - $config['buckets'], - $config['databases'], - $config['console'] - ); + $collections = \array_merge( + $config['projects'], + $config['buckets'], + $config['databases'], + $config['console'] + ); - $collection = $collections[$collection]; + $collection = $collections[$collection]; + } $allowedAttributesLookup = []; foreach ($allowedAttributes as $attribute) { diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Executions.php b/src/Appwrite/Utopia/Database/Validator/Queries/Executions.php index 4c0a38b46f..92b915daf8 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Executions.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Executions.php @@ -2,8 +2,20 @@ namespace Appwrite\Utopia\Database\Validator\Queries; +use Utopia\Database\Database; + class Executions extends Base { + public const ATTRIBUTES = [ + ['$id' => 'trigger', 'type' => Database::VAR_STRING, 'array' => false], + ['$id' => 'status', 'type' => Database::VAR_STRING, 'array' => false], + ['$id' => 'responseStatusCode', 'type' => Database::VAR_INTEGER, 'array' => false], + ['$id' => 'duration', 'type' => Database::VAR_FLOAT, 'array' => false], + ['$id' => 'requestMethod', 'type' => Database::VAR_STRING, 'array' => false], + ['$id' => 'requestPath', 'type' => Database::VAR_STRING, 'array' => false], + ['$id' => 'deploymentId', 'type' => Database::VAR_STRING, 'array' => false], + ]; + public const ALLOWED_ATTRIBUTES = [ 'trigger', 'status', @@ -20,6 +32,6 @@ class Executions extends Base */ public function __construct() { - parent::__construct('executions', self::ALLOWED_ATTRIBUTES); + parent::__construct(['attributes' => self::ATTRIBUTES], self::ALLOWED_ATTRIBUTES); } } diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Logs.php b/src/Appwrite/Utopia/Database/Validator/Queries/Logs.php index d07d3dd3d2..ab1982c29f 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Logs.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Logs.php @@ -19,6 +19,6 @@ class Logs extends Base */ public function __construct() { - parent::__construct('executions', self::ALLOWED_ATTRIBUTES); //TODO: Update this later + parent::__construct(['attributes' => Executions::ATTRIBUTES], self::ALLOWED_ATTRIBUTES); } } diff --git a/tests/unit/General/CollectionsTest.php b/tests/unit/General/CollectionsTest.php index d90905abda..1a125656f3 100644 --- a/tests/unit/General/CollectionsTest.php +++ b/tests/unit/General/CollectionsTest.php @@ -4,7 +4,10 @@ declare(strict_types=1); namespace Tests\Unit\General; +use Appwrite\Utopia\Database\Validator\Queries\Executions; +use Appwrite\Utopia\Database\Validator\Queries\Logs; use PHPUnit\Framework\TestCase; +use Utopia\Database\Query; final class CollectionsTest extends TestCase { @@ -33,4 +36,19 @@ final class CollectionsTest extends TestCase } } } + + public function testProjectsDoNotDefineExecutionsCollection(): void + { + $this->assertArrayNotHasKey('executions', $this->collections['projects']); + } + + public function testExecutionQueryValidatorsDoNotNeedCollectionSchema(): void + { + $this->assertTrue((new Executions())->isValid([ + Query::equal('status', ['completed']), + ])); + $this->assertTrue((new Logs())->isValid([ + Query::equal('status', ['completed']), + ])); + } }