From 2bc1fbedd7af232b97b015d7436af6b321b8b3b2 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 3 Jun 2026 09:34:23 +0100 Subject: [PATCH 1/4] Expose project region in response model --- src/Appwrite/Utopia/Response/Model/Project.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index c788833e88..29d7964e0a 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -43,6 +43,12 @@ class Project extends Model 'default' => '', 'example' => '1592981250', ]) + ->addRule('region', [ + 'type' => self::TYPE_STRING, + 'description' => 'Project region.', + 'default' => 'default', + 'example' => 'fra', + ]) // Resource: Dev Keys ->addRule('devKeys', [ From a0256d7cbf146ca671a517e40f40c6eb256b941b Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 3 Jun 2026 09:46:27 +0100 Subject: [PATCH 2/4] Expose project blocks and console access time --- .../Utopia/Response/Model/Project.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index 29d7964e0a..d475cfe5f2 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -179,6 +179,19 @@ class Project extends Model 'example' => new \stdClass(), 'array' => true, ]) + ->addRule('blocks', [ + 'type' => self::TYPE_STRING, + 'description' => 'Project blocks information.', + 'default' => [], + 'example' => [], + 'array' => true, + ]) + ->addRule('consoleAccessedAt', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Last time the project was accessed via console.', + 'default' => '', + 'example' => self::TYPE_DATETIME_EXAMPLE, + ]) ; } @@ -213,10 +226,16 @@ class Project extends Model $this->expandServices($document); $this->expandProtocols($document); $this->expandAuthMethods($document); + $this->expandConsoleAccessedAt($document); return $document; } + private function expandConsoleAccessedAt(Document $document): void + { + $document->setAttribute('consoleAccessedAt', $document->getAttribute('accessedAt', '')); + } + private function expandSmtpFields(Document $document): void { if (!$document->isSet('smtp')) { From 57d21e283dfb1b6cb56251e329629d3f5b905bef Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 3 Jun 2026 09:57:07 +0100 Subject: [PATCH 3/4] Relax migration smoke status counters assertion --- tests/e2e/Services/Migrations/MigrationsBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index c4bfb585a2..6509a35de8 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -225,8 +225,8 @@ trait MigrationsBase $this->assertEquals('Appwrite', $response['source']); $this->assertEquals('Appwrite', $response['destination']); + $this->assertArrayHasKey(Resource::TYPE_API_KEY, $response['statusCounters']); $counts = $response['statusCounters'][Resource::TYPE_API_KEY]; - $this->assertEquals([Resource::TYPE_API_KEY], array_keys($response['statusCounters'])); $this->assertEquals(0, $counts['error']); $this->assertGreaterThan(0, $counts['success']); } From 9a7b6f6f035493ac62e64977f3263e5b7efb6300 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Wed, 3 Jun 2026 10:16:38 +0100 Subject: [PATCH 4/4] Clean migrated project variables in E2E --- .../Services/Migrations/MigrationsBase.php | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index a0c6de3e59..0cafd64975 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -11,6 +11,7 @@ use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Services\Functions\FunctionsBase; use Utopia\Console; use Utopia\Database\Database; +use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; @@ -2641,6 +2642,35 @@ trait MigrationsBase 'x-appwrite-key' => $this->getDestinationProject()['apiKey'], ]; + $listDestinationVariables = function () use ($destinationHeaders): array { + $variables = []; + $cursorId = null; + + do { + $queries = [ + Query::limit(100)->toString(), + ]; + + if ($cursorId !== null) { + $queries[] = Query::cursorAfter(new Document(['$id' => $cursorId]))->toString(); + } + + $response = $this->client->call(Client::METHOD_GET, '/project/variables', $destinationHeaders, [ + 'queries' => $queries, + 'total' => false, + ]); + $this->assertEquals(200, $response['headers']['status-code']); + + $batch = $response['body']['variables']; + array_push($variables, ...$batch); + $cursorId = !empty($batch) ? $batch[array_key_last($batch)]['$id'] : null; + } while (\count($batch) === 100); + + return $variables; + }; + + $existingDestinationVariableIds = \array_flip(\array_column($listDestinationVariables(), '$id')); + // Source-side variable IDs and keys are uniquified so re-runs and parallel suites // can't trip the source-side findOne('variables', [key=...]) skip path. $plainKey = 'TEST_PLAIN_' . \strtoupper(ID::unique()); @@ -2685,12 +2715,11 @@ trait MigrationsBase $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_VARIABLE]['processing']); $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROJECT_VARIABLE]['warning']); - $response = $this->client->call(Client::METHOD_GET, '/project/variables', $destinationHeaders); - $this->assertEquals(200, $response['headers']['status-code']); + $destinationVariables = $listDestinationVariables(); $foundPlain = null; $foundSecret = null; - foreach ($response['body']['variables'] as $v) { + foreach ($destinationVariables as $v) { if ($v['key'] === $plainKey) { $foundPlain = $v; } elseif ($v['key'] === $secretKey) { @@ -2710,9 +2739,13 @@ trait MigrationsBase $this->assertEmpty($foundSecret['value']); $this->assertTrue($foundSecret['secret']); - // Cleanup on destination - $this->client->call(Client::METHOD_DELETE, '/project/variables/' . $foundPlain['$id'], $destinationHeaders); - $this->client->call(Client::METHOD_DELETE, '/project/variables/' . $foundSecret['$id'], $destinationHeaders); + // Cleanup every destination variable this migration added, including any + // unrelated source variables copied by the resource-level migration. + foreach ($destinationVariables as $variable) { + if (!isset($existingDestinationVariableIds[$variable['$id']])) { + $this->client->call(Client::METHOD_DELETE, '/project/variables/' . $variable['$id'], $destinationHeaders); + } + } // Cleanup on source $this->client->call(Client::METHOD_DELETE, '/project/variables/' . $plainVariable['$id'], $sourceHeaders);