mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Add Protocols migration support
- Bump utopia-php/migration to add-protocols-migration dev branch - MigrationReport rule for TYPE_PROTOCOLS - E2E: testAppwriteMigrationProtocols flips graphql + websocket on source, runs migration, asserts both land disabled on destination
This commit is contained in:
+1
-1
@@ -74,7 +74,7 @@
|
||||
"utopia-php/locale": "0.8.*",
|
||||
"utopia-php/logger": "0.8.*",
|
||||
"utopia-php/messaging": "0.22.*",
|
||||
"utopia-php/migration": "dev-add-auth-methods-migration as 1.12.0",
|
||||
"utopia-php/migration": "dev-add-protocols-migration as 1.12.0",
|
||||
"utopia-php/platform": "^1.0@RC",
|
||||
"utopia-php/pools": "1.*",
|
||||
"utopia-php/span": "1.1.*",
|
||||
|
||||
Generated
+8
-8
@@ -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": "9623d2109a32041ca4e395ab55266038",
|
||||
"content-hash": "13f0750846460bcf452f4c678ba570f8",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
@@ -4606,16 +4606,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/migration",
|
||||
"version": "dev-add-auth-methods-migration",
|
||||
"version": "dev-add-protocols-migration",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/migration.git",
|
||||
"reference": "5224e3ce9a96373dfd83648b5e8e4e4d20b85020"
|
||||
"reference": "d74e8cbd195f341810ec75adaf620447214fc110"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/migration/zipball/5224e3ce9a96373dfd83648b5e8e4e4d20b85020",
|
||||
"reference": "5224e3ce9a96373dfd83648b5e8e4e4d20b85020",
|
||||
"url": "https://api.github.com/repos/utopia-php/migration/zipball/d74e8cbd195f341810ec75adaf620447214fc110",
|
||||
"reference": "d74e8cbd195f341810ec75adaf620447214fc110",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -4672,10 +4672,10 @@
|
||||
"utopia"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/utopia-php/migration/tree/add-auth-methods-migration",
|
||||
"source": "https://github.com/utopia-php/migration/tree/add-protocols-migration",
|
||||
"issues": "https://github.com/utopia-php/migration/issues"
|
||||
},
|
||||
"time": "2026-05-18T12:08:47+00:00"
|
||||
"time": "2026-05-18T13:09:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/mongo",
|
||||
@@ -8585,7 +8585,7 @@
|
||||
"aliases": [
|
||||
{
|
||||
"package": "utopia-php/migration",
|
||||
"version": "dev-add-auth-methods-migration",
|
||||
"version": "dev-add-protocols-migration",
|
||||
"alias": "1.12.0",
|
||||
"alias_normalized": "1.12.0.0"
|
||||
}
|
||||
|
||||
@@ -83,6 +83,12 @@ class MigrationReport extends Model
|
||||
'default' => 0,
|
||||
'example' => 1,
|
||||
])
|
||||
->addRule(Resource::TYPE_PROTOCOLS, [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Number of protocol configs to be migrated (always 0 or 1 — the project-level REST/GraphQL/WebSocket flags).',
|
||||
'default' => 0,
|
||||
'example' => 1,
|
||||
])
|
||||
->addRule(Resource::TYPE_SITE, [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Number of sites to be migrated.',
|
||||
|
||||
@@ -2750,6 +2750,56 @@ trait MigrationsBase
|
||||
$this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/auth/jwt', $consoleHeaders, ['status' => true]);
|
||||
}
|
||||
|
||||
public function testAppwriteMigrationProtocols(): void
|
||||
{
|
||||
$consoleHeaders = [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => 'console',
|
||||
'origin' => 'http://localhost',
|
||||
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
|
||||
];
|
||||
|
||||
$sourceProjectId = $this->getProject()['$id'];
|
||||
// Flip graphql + websocket off on source to make the round-trip observable.
|
||||
$this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/graphql', $consoleHeaders, [
|
||||
'status' => false,
|
||||
]);
|
||||
$this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/websocket', $consoleHeaders, [
|
||||
'status' => false,
|
||||
]);
|
||||
|
||||
$result = $this->performMigrationSync([
|
||||
'resources' => [
|
||||
Resource::TYPE_PROTOCOLS,
|
||||
],
|
||||
'endpoint' => $this->webEndpoint,
|
||||
'projectId' => $sourceProjectId,
|
||||
'apiKey' => $this->getProject()['apiKey'],
|
||||
]);
|
||||
|
||||
$this->assertEquals('completed', $result['status']);
|
||||
$this->assertEquals([Resource::TYPE_PROTOCOLS], $result['resources']);
|
||||
$this->assertArrayHasKey(Resource::TYPE_PROTOCOLS, $result['statusCounters']);
|
||||
$this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['error']);
|
||||
$this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['pending']);
|
||||
$this->assertEquals(1, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['success']);
|
||||
$this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['processing']);
|
||||
$this->assertEquals(0, $result['statusCounters'][Resource::TYPE_PROTOCOLS]['warning']);
|
||||
|
||||
$destinationProjectId = $this->getDestinationProject()['$id'];
|
||||
$response = $this->client->call(Client::METHOD_GET, '/projects/' . $destinationProjectId, $consoleHeaders);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertFalse($response['body']['protocolStatusForGraphql'], 'GraphQL protocol should be migrated as disabled');
|
||||
$this->assertFalse($response['body']['protocolStatusForWebsocket'], 'WebSocket protocol should be migrated as disabled');
|
||||
|
||||
// Restore both projects so the test is idempotent.
|
||||
$this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/graphql', $consoleHeaders, ['status' => true]);
|
||||
$this->client->call(Client::METHOD_PATCH, '/projects/' . $sourceProjectId . '/api/websocket', $consoleHeaders, ['status' => true]);
|
||||
$this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/api/graphql', $consoleHeaders, ['status' => true]);
|
||||
$this->client->call(Client::METHOD_PATCH, '/projects/' . $destinationProjectId . '/api/websocket', $consoleHeaders, ['status' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Import documents from a CSV file.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user