8000 Fix indexes for `1.7.x` by ItzNotABug · Pull Request #9752 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix indexes for 1.7.x #9752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/config/collections/platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@
[
'$id' => ID::custom('_key_piid_riid_rt'),
'type' => Database::INDEX_KEY,
'attributes' => ['projectInternalId', 'resourceInternalId', 'resourceType'],
'attributes' => ['projectInternalId', 'deploymentInternalId', 'deploymentResourceType'],
Copy link
@coderabbitai coderabbitai bot May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Index attributes updated to align with deployment terminology

The attributes for the _key_piid_riid_rt index have been updated from resource-based to deployment-based identifiers, which aligns with modern deployment-focused architecture.

Let's verify that this change has been consistently applied across the codebase:


🏁 Script executed:

#!/bin/bash
# Search for any c
8000
ode that might be using the old index attributes
rg "resourceInternalId.*resourceType" --type php

Length of output: 5420


Inconsistent index definitions: update remaining resource-based indexes

I see the _key_piid_riid_rt index in app/config/collections/platform.php has been updated to use deploymentInternalId and deploymentResourceType, but there are still other index definitions that reference the old resourceInternalId/resourceType fields. Please update these to match the new deployment-based naming:

  • app/config/collections/platform.php
    • Index on ['projectInternalId', 'resourceInternalId', 'resourceType']
  • app/config/collections/projects.php
    • Multiple indexes with ['resourceInternalId', 'resourceType']
    _key_resourceInternalId_resourceType

Once these are updated, all platform- and project-collection indexes will consistently use deploymentInternalId and deploymentResourceType.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those work fine because they have the same attributes. the docker build on local went fine and the stack started fine as well without any errors.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ItzNotABug Thanks for the clarification. I understand that both naming patterns are functionally equivalent and your local testing confirms everything works properly. While standardizing the naming across all indexes could help with code readability and maintenance in the future, it's not causing any functional issues.

Would you like me to stop flagging these naming inconsistencies in this PR since your primary goal is to fix specific indexes for version 1.7.x rather than standardizing all names?

(_/)
( •_•)
/ >🐰 Curious about your priorities for this PR


✏️ Learnings added
Learnt from: ItzNotABug
PR: appwrite/appwrite#9752
File: app/config/collections/platform.php:1423-1423
Timestamp: 2025-05-13T12:02:08.046Z
Learning: In the Appwrite database schema, field names like 'resourceInternalId'/'resourceType' and 'deploymentInternalId'/'deploymentResourceType' are functionally equivalent and can coexist in the codebase without causing errors. The docker build and stack work fine with these naming inconsistencies.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

'lengths' => [],
'orders' => [],
],
Expand Down
2 changes: 1 addition & 1 deletion app/config/collections/projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,7 @@
[
'$id' => ID::custom('_key_function_internal_id'),
'type' => Database::INDEX_KEY,
'attributes' => ['functionInternalId'],
'attributes' => ['resourceInternalId'],
'lengths' => [],
'orders' => [],
],
Expand Down
141 changes: 71 additions & 70 deletions composer.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public function action(
'totalSize' => $deployment->getAttribute('sourceSize', 0),
'entrypoint' => $function->getAttribute('entrypoint'),
'buildCommands' => $function->getAttribute('commands', ''),
'search' => implode(' ', [$deploymentId, $function->getAttribute('entrypoint')]),
'buildStartedAt' => null,
'buildEndedAt' => null,
'buildDuration' => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ function: $function,
'entrypoint' => $function->getAttribute('entrypoint', ''),
'buildCommands' => $function->getAttribute('commands', ''),
'type' => 'manual',
'search' => implode(' ', [$deploymentId, $function->getAttribute('entrypoint', '')]),
'activate' => $activate,
]));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public function action(
'buildOutput' => $site->getAttribute('outputDirectory', ''),
'adapter' => $site->getAttribute('adapter', ''),
'fallbackFile' => $site->getAttribute('fallbackFile', ''),
'search' => implode(' ', [$deploymentId]),
'screenshotLight' => '',
'screenshotDark' => '',
'buildStartedAt' => null,
Expand Down Expand Up @@ -162,7 +161,6 @@ public function action(
'deploymentResourceInternalId' => $site->getInternalId(),
'status' => 'verified',
'certificateId' => '',
'search' => implode(' ', [$ruleId, $domain]),
'owner' => 'Appwrite',
'region' => $project->getAttribute('region')
]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ public function action(
'adapter' => $site->getAttribute('adapter', ''),
'fallbackFile' => $site->getAttribute('fallbackFile', ''),
'type' => 'manual',
'search' => implode(' ', [$deploymentId]),
'activate' => $activate,
]));

Expand Down Expand Up @@ -192,7 +191,6 @@ public function action(
'deploymentResourceInternalId' => $site->getInternalId(),
'status' => 'verified',
'certificateId' => '',
'search' => implode(' ', [$ruleId, $domain]),
'owner' => 'Appwrite',
'region' => $project->getAttribute('region')
]))
Expand Down
13 changes: 4 additions & 9 deletions tests/e2e/Services/Functions/FunctionsCustomServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public function testCreateFunctionAndDeploymentFromTemplate()
$deployment = $this->createTemplateDeployment(
$functionId,
[
'functionId' => ID::unique(),
'resourceId' => ID::unique(),
'activate' => true,
'repository' => $starterTemplate['body']['providerRepositoryId'],
'owner' => $starterTemplate['body']['providerOwner'],
Expand Down Expand Up @@ -728,18 +728,13 @@ public function testListDeployments(array $data): array
],
]);

$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(200, $deployments['headers']['status-code']);
$this->assertCount(2, $deployments['body']['deployments']);

$deployments = $this->listDeployments($functionId, [
'search' => 'php-8.0'
]);
$deployments = $this->listDeployments($functionId);

$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(3, $deployments['body']['total']);
$this->assertIsArray($deployments['body']['deployments']);
$this->assertCount(3, $deployments['body']['deployments']);
$this->assertEquals($deployments['body']['deployments'][0]['$id'], $data['deploymentId']);
$this->assertEquals(200, $deployments['headers']['status-code']);

$deployments = $this->listDeployments(
$functionId,
Expand Down
9 changes: 4 additions & 5 deletions tests/e2e/Services/Projects/ProjectsConsoleClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4454,13 +4454,12 @@ public function testListProjectDevKey(): void
$response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => 'Dev'
]);
], $this->getHeaders()));

$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(1, $response['body']['total']);
$this->assertEquals('Dev Key Test', $response['body']['devKeys'][0]['name']);
$this->assertEquals(2, $response['body']['total']);
$this->assertEquals('Key Test', $response['body']['devKeys'][0]['name']);
$this->assertEquals('Dev Key Test', $response['body']['devKeys'][1]['name']);

/** List dev keys with querying `expire` */
$response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys', array_merge([
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/Services/Sites/SitesCustomServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,7 @@ public function testListSites(): void
'siteId' => ID::unique()
]);

$sites = $this->listSites([
'search' => $siteId,
]);
$sites = $this->listSites();

$this->assertEquals($sites['headers']['status-code'], 200);
$this->assertCount(1, $sites['body']['sites']);
Expand Down
0