diff --git a/src/Appwrite/Migration/Version/V16.php b/src/Appwrite/Migration/Version/V16.php index 636a301717..49f244598e 100644 --- a/src/Appwrite/Migration/Version/V16.php +++ b/src/Appwrite/Migration/Version/V16.php @@ -48,36 +48,6 @@ class V16 extends Migration $this->projectDB->setNamespace("_{$this->project->getInternalId()}"); switch ($id) { - case 'executions': - try { - /** - * Create 'scheduledAt' attribute - */ - $this->createAttributeFromCollection($this->projectDB, $id, 'scheduledAt'); - } catch (\Throwable $th) { - Console::warning("'scheduledAt' from {$id}: {$th->getMessage()}"); - } - - try { - /** - * Create 'scheduleInternalId' attribute - */ - $this->createAttributeFromCollection($this->projectDB, $id, 'scheduleInternalId'); - } catch (\Throwable $th) { - Console::warning("'scheduleInternalId' from {$id}: {$th->getMessage()}"); - } - - try { - /** - * Create 'scheduleId' attribute - */ - $this->createAttributeFromCollection($this->projectDB, $id, 'scheduleId'); - } catch (\Throwable $th) { - Console::warning("'scheduleId' from {$id}: {$th->getMessage()}"); - } - - break; - case 'sessions': try { /** diff --git a/src/Appwrite/Migration/Version/V21.php b/src/Appwrite/Migration/Version/V21.php index be6c38be67..1eda618c52 100644 --- a/src/Appwrite/Migration/Version/V21.php +++ b/src/Appwrite/Migration/Version/V21.php @@ -69,6 +69,35 @@ class V21 extends Migration Console::warning("'accessedAt' from {$id}: {$th->getMessage()}"); } break; + case 'executions': + try { + /** + * Create 'scheduledAt' attribute + */ + $this->createAttributeFromCollection($this->projectDB, $id, 'scheduledAt'); + } catch (\Throwable $th) { + Console::warning("'scheduledAt' from {$id}: {$th->getMessage()}"); + } + + try { + /** + * Create 'scheduleInternalId' attribute + */ + $this->createAttributeFromCollection($this->projectDB, $id, 'scheduleInternalId'); + } catch (\Throwable $th) { + Console::warning("'scheduleInternalId' from {$id}: {$th->getMessage()}"); + } + + try { + /** + * Create 'scheduleId' attribute + */ + $this->createAttributeFromCollection($this->projectDB, $id, 'scheduleId'); + } catch (\Throwable $th) { + Console::warning("'scheduleId' from {$id}: {$th->getMessage()}"); + } + + break; case 'schedules': // Create data attribute try { diff --git a/src/Appwrite/Utopia/Response/Filters/V18.php b/src/Appwrite/Utopia/Response/Filters/V18.php index b32856bdb4..d0aa680e3b 100644 --- a/src/Appwrite/Utopia/Response/Filters/V18.php +++ b/src/Appwrite/Utopia/Response/Filters/V18.php @@ -14,6 +14,7 @@ class V18 extends Filter $parsedResponse = match($model) { Response::MODEL_FUNCTION => $this->parseFunction($content), + Response::MODEL_EXECUTION => $this->parseExecution($content), Response::MODEL_PROJECT => $this->parseProject($content), default => $parsedResponse, }; @@ -21,6 +22,12 @@ class V18 extends Filter return $parsedResponse; } + protected function parseExecution(array $content) + { + unset($content['scheduledAt']); + return $content; + } + protected function parseFunction(array $content) { unset($content['scopes']); diff --git a/tests/unit/Utopia/Response/Filters/V18Test.php b/tests/unit/Utopia/Response/Filters/V18Test.php index 36719a7620..c4011c08a1 100644 --- a/tests/unit/Utopia/Response/Filters/V18Test.php +++ b/tests/unit/Utopia/Response/Filters/V18Test.php @@ -50,6 +50,32 @@ class V18Test extends TestCase $this->assertEquals($expected, $result); } + + public function executionProvider(): array + { + return [ + 'remove scheduledAt' => [ + [ + 'scheduledAt' => '2024-07-13T09:00:00.000Z', + ], + [ + ] + ] + ]; + } + + /** + * @dataProvider executionProvider + */ + public function testExecution(array $content, array $expected): void + { + $model = Response::MODEL_EXECUTION; + + $result = $this->filter->parse($content, $model); + + $this->assertEquals($expected, $result); + } + public function projectProvider(): array { return [