diff --git a/composer.json b/composer.json index ccba92ff9d..9a13d112b3 100644 --- a/composer.json +++ b/composer.json @@ -74,7 +74,7 @@ "utopia-php/locale": "0.8.*", "utopia-php/logger": "0.8.*", "utopia-php/messaging": "0.22.*", - "utopia-php/migration": "dev-add-labels-migration as 1.12.0", + "utopia-php/migration": "dev-add-services-migration as 1.12.0", "utopia-php/platform": "^1.0@RC", "utopia-php/pools": "1.*", "utopia-php/span": "1.1.*", diff --git a/composer.lock b/composer.lock index f52056dc9a..e666b5ffc6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e553f40900362e52e8cf7ab59f3628bc", + "content-hash": "55e6e4d5d59d83661dea4b04e913c986", "packages": [ { "name": "adhocore/jwt", @@ -4606,16 +4606,16 @@ }, { "name": "utopia-php/migration", - "version": "dev-add-labels-migration", + "version": "dev-add-services-migration", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "b7b64ac3ed6359d9c9f7ccaa6a53b2f6dca89edc" + "reference": "2f7270734300d4f5ac450a9bb3d0e11b32986a53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/b7b64ac3ed6359d9c9f7ccaa6a53b2f6dca89edc", - "reference": "b7b64ac3ed6359d9c9f7ccaa6a53b2f6dca89edc", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/2f7270734300d4f5ac450a9bb3d0e11b32986a53", + "reference": "2f7270734300d4f5ac450a9bb3d0e11b32986a53", "shasum": "" }, "require": { @@ -4672,10 +4672,10 @@ "utopia" ], "support": { - "source": "https://github.com/utopia-php/migration/tree/add-labels-migration", + "source": "https://github.com/utopia-php/migration/tree/add-services-migration", "issues": "https://github.com/utopia-php/migration/issues" }, - "time": "2026-05-18T14:18:57+00:00" + "time": "2026-05-18T15:10:10+00:00" }, { "name": "utopia-php/mongo", @@ -8585,7 +8585,7 @@ "aliases": [ { "package": "utopia-php/migration", - "version": "dev-add-labels-migration", + "version": "dev-add-services-migration", "alias": "1.12.0", "alias_normalized": "1.12.0.0" } diff --git a/src/Appwrite/Utopia/Response/Model/MigrationReport.php b/src/Appwrite/Utopia/Response/Model/MigrationReport.php index f2f5043776..2096a73bda 100644 --- a/src/Appwrite/Utopia/Response/Model/MigrationReport.php +++ b/src/Appwrite/Utopia/Response/Model/MigrationReport.php @@ -95,6 +95,12 @@ class MigrationReport extends Model 'default' => 0, 'example' => 1, ]) + ->addRule(Resource::TYPE_SERVICES, [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Number of service configs to be migrated (always 0 or 1 — the project-level enable/disable flags for all 17 services).', + 'default' => 0, + 'example' => 1, + ]) ->addRule(Resource::TYPE_SITE, [ 'type' => self::TYPE_INTEGER, 'description' => 'Number of sites to be migrated.', diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index af3a5ddb63..e061b65f7b 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -2853,6 +2853,52 @@ trait MigrationsBase ]); } + public function testAppwriteMigrationServices(): void + { + $consoleHeaders = [ + 'content-type' => 'application/json', + 'x-appwrite-project' => 'console', + 'origin' => 'http://localhost', + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + ]; + + $sourceProjectId = $this->getProject()['$id']; + $destinationProjectId = $this->getDestinationProject()['$id']; + + // Disable functions + graphql on source as observable changes. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/functions', $consoleHeaders, ['status' => false]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/graphql', $consoleHeaders, ['status' => false]); + + $result = $this->performMigrationSync([ + 'resources' => [ + Resource::TYPE_SERVICES, + ], + 'endpoint' => $this->webEndpoint, + 'projectId' => $sourceProjectId, + 'apiKey' => $this->getProject()['apiKey'], + ]); + + $this->assertEquals('completed', $result['status']); + $this->assertEquals([Resource::TYPE_SERVICES], $result['resources']); + $this->assertArrayHasKey(Resource::TYPE_SERVICES, $result['statusCounters']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['error']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['pending']); + $this->assertEquals(1, $result['statusCounters'][Resource::TYPE_SERVICES]['success']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['processing']); + $this->assertEquals(0, $result['statusCounters'][Resource::TYPE_SERVICES]['warning']); + + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertFalse($response['body']['serviceStatusForFunctions'], 'Functions service should be migrated as disabled'); + $this->assertFalse($response['body']['serviceStatusForGraphql'], 'GraphQL service should be migrated as disabled'); + + // Restore both projects. + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/functions', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/service/graphql', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/service/functions', $consoleHeaders, ['status' => true]); + $this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/service/graphql', $consoleHeaders, ['status' => true]); + } + /** * Import documents from a CSV file. */