Skip to content

Add backup policy migration support#11632

Open
premtsd-code wants to merge 9 commits into1.9.xfrom
backup-migration-multitype
Open

Add backup policy migration support#11632
premtsd-code wants to merge 9 commits into1.9.xfrom
backup-migration-multitype

Conversation

@premtsd-code
Copy link
Copy Markdown
Contributor

Summary

  • Extract API key scopes into getAPIKeyScopes() method in Migrations worker for extensibility by Cloud
  • Allows Cloud to override scopes and add backup policy-specific scopes (policies.read, policies.write)

Test plan

  • Verify existing migration tests pass
  • Verify Cloud can override getAPIKeyScopes() to add backup policy scopes
  • Test backup policy migration end-to-end in Cloud environment

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5f26734b-cb5d-4e62-b7de-78e9d8e1c113

📥 Commits

Reviewing files that changed from the base of the PR and between 6128a04 and 2838642.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • tests/e2e/Scopes/ProjectCustom.php
✅ Files skipped from review due to trivial changes (1)
  • tests/e2e/Scopes/ProjectCustom.php

📝 Walkthrough

Walkthrough

A new protected helper getAPIKeyScopes(): array was added to src/Appwrite/Platform/Workers/Migrations.php, and generateAPIKey() was updated to use this helper for its 'scopes' value instead of an inline array. tests/e2e/Scopes/ProjectCustom.php was updated to include policies.read and policies.write in the created API key's scopes. composer.json was changed to replace the utopia-php/migration constraint 1.8.* with dev-backup-migration-multitype as 1.8.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: extracting and enabling backup policy migration support through API scope extensibility.
Description check ✅ Passed The description directly relates to the changeset, explaining the scope extraction, extensibility mechanism for Cloud, and test verification steps for backup policy migrations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backup-migration-multitype

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 24, 2026

Greptile Summary

This PR performs a small, focused refactoring in src/Appwrite/Platform/Workers/Migrations.php: the previously inline scopes array inside generateAPIKey() is extracted into a new protected function getAPIKeyScopes(): array method. The list of scopes is identical to what was hardcoded before, so there is no behaviour change for existing consumers. The protected visibility is the right choice here — it allows Cloud (which presumably subclasses Migrations) to override the method and append backup-policy-specific scopes (policies.read, policies.write) without modifying the open-source base class.

  • Purely a refactor — no logic or scope changes in the base class.
  • protected visibility is correct for the intended inheritance pattern.
  • The trailing comma added on the last array element ('project.write',) is harmless valid PHP syntax.

Confidence Score: 5/5

  • This PR is safe to merge — it is a pure refactor with no behaviour change in the base class.
  • The change extracts an identical list of scopes into a new overridable method. No logic is altered, no new scopes are added to the open-source path, and the protected visibility is appropriate for the inheritance pattern described. Risk is minimal.
  • No files require special attention.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Workers/Migrations.php Extracts the hardcoded API key scopes array from generateAPIKey() into a new protected getAPIKeyScopes() method, enabling subclasses to override and extend the scopes (e.g. adding policies.read/policies.write for Cloud backup policy migration). The scopes list itself is unchanged.

Reviews (1): Last reviewed commit: "Merge 1.9.x and add new API key scopes" | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

🔄 PHP-Retry Summary

Flaky tests detected across commits:

Commit 6f73602 - 6 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.12s Logs
DocumentsDBCustomServerTest::testTimeout 1 121.06s Logs
LegacyConsoleClientTest::testListDocumentsCacheBustedByAttributeChange 1 522ms Logs
LegacyConsoleClientTest::testTimeout 1 122.06s Logs
LegacyCustomClientTest::testTimeout 1 121.42s Logs
LegacyCustomServerTest::testCreateAttributes 1 242.23s Logs
Commit 9ba6bfb - 1 flaky test
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.53s Logs
Commit bd03ec7 - 6 flaky tests
Test Retries Total Time Details
DocumentsDBCustomServerTest::testTimeout 1 121.03s Logs
LegacyCustomClientTest::testAttributeResponseModels 1 242.14s Logs
LegacyCustomClientTest::testInvalidDocumentStructure 1 240.46s Logs
LegacyCustomServerTest::testAttributeResponseModels 1 242.51s Logs
LegacyPermissionsGuestTest::testWriteDocumentWithPermissions 1 240.24s Logs
UsageTest::testVectorsDBStats 1 10.07s Logs
Commit d993214 - 4 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.01s Logs
DocumentsDBCustomClientTest::testTimeout 1 120.09s Logs
DocumentsDBCustomServerTest::testTimeout 1 120.78s Logs
LegacyConsoleClientTest::testListDocuments 1 120.09s Logs
Commit 28882a4 - 2 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.20s Logs
DatabaseServerTest::testCreateRow 1 240.79s Logs

Note: Flaky test results are tracked for the last 5 commits

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

✨ Benchmark results

  • Requests per second: 1,554
  • Requests with 200 status code: 279,858
  • P99 latency: 0.112926368

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,554 1,114
200 279,858 200,623
P99 0.112926368 0.197563908

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
composer.json (1)

76-76: Pinning the commit reference in composer.json is optional—reproducibility is already ensured by composer.lock.

While dev-backup-migration-multitype as 1.8.0 points to a dev branch, the corresponding composer.lock entry already pins the concrete commit SHA (8633523b3343d492427331b6eec53f020f6ab7a7). Developers will install the locked version, ensuring reproducibility. For consistency and clarity, you may optionally update composer.json to pin the commit directly, but it is not required for stability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@composer.json` at line 76, The dependency entry "utopia-php/migration":
"dev-backup-migration-multitype as 1.8.0" in composer.json is referencing a
branch alias; to make the source explicit (optional), replace the branch alias
with the concrete commit reference used in composer.lock (e.g., use the VCS
commit SHA) or leave it as-is since composer.lock already pins the exact commit;
locate the dependency string in composer.json and either update its version
value to the commit reference (the same SHA shown in composer.lock) or document
that no change is required because composer.lock ensures reproducible installs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@composer.json`:
- Line 76: The dependency entry "utopia-php/migration":
"dev-backup-migration-multitype as 1.8.0" in composer.json is referencing a
branch alias; to make the source explicit (optional), replace the branch alias
with the concrete commit reference used in composer.lock (e.g., use the VCS
commit SHA) or leave it as-is since composer.lock already pins the exact commit;
locate the dependency string in composer.json and either update its version
value to the commit reference (the same SHA shown in composer.lock) or document
that no change is required because composer.lock ensures reproducible installs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 13692d5e-3eb5-4c0e-a698-dedaac43bbfe

📥 Commits

Reviewing files that changed from the base of the PR and between b1e97b4 and 6128a04.

📒 Files selected for processing (1)
  • composer.json

@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

@blacksmith-sh
Copy link
Copy Markdown

blacksmith-sh bot commented Mar 24, 2026

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
› Tests\E2E\Services\Realtime\RealtimeCustomClientTest/testChannelTablesDBRowUpdate View Logs

Fix in Cursor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant