Skip to content

feat(migrations): expose queryable resource links#12193

Open
abnegate wants to merge 8 commits into
1.9.xfrom
feat/migration-resource-attrs
Open

feat(migrations): expose queryable resource links#12193
abnegate wants to merge 8 commits into
1.9.xfrom
feat/migration-resource-attrs

Conversation

@abnegate

@abnegate abnegate commented May 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Splits legacy databaseId:collectionId migration values into explicit leaf resourceId/resourceType and parentResourceId/parentResourceType fields, with internal IDs stored separately.
  • Adds destinationResourceId and destinationResourceType so migrations can be linked to a destination known at request creation.
  • Makes source, parent, and destination public resource fields queryable.
  • Updates CSV and JSON import/export endpoints to accept separate databaseId and collectionId parameters.
  • Adds an idempotent V25 schema/data migration plus V27 request/response filters for pre-1.9.6 SDK compatibility.
  • Keeps the existing _key_resource_id index and adds one index per new query field, matching the Cloud rollout schema.
  • Runs adapter success hooks before persisting a completed migration, so finalization failures follow the normal failed-state path.
  • Preserves unresolved legacy composite resource IDs and types until both parent and leaf internal IDs resolve.
  • Normalizes nullable legacy selector types to the empty-string behavior expected by the strict compatibility bridge.

Database lookup contract

Canonical operational selector types are database for TablesDB and legacy database roots, documentsdb, and vectorsdb. The public tablesdb alias is normalized to database; tablesdb is not stored in the migration selector fields.

A database history lookup is an OR across these independently queryable pairs:

  • resourceType and resourceId for a source root
  • parentResourceType and parentResourceId when the migration leaf belongs to a database
  • destinationResourceType and destinationResourceId for the recovered database

The operational contract is therefore not a single resourceType + resourceId equality for every migration shape.

Destination ownership

CSV and JSON imports persist the destination database immediately because it already exists and is known synchronously.

Full Appwrite or backup transfers intentionally do not infer destination IDs from worker callbacks, cache entries, or reports. Those values can be ambiguous during overwrite and temporary-ID flows. Cloud backup restore owns that linkage by resolving the requested target before enqueue.

Compatibility

  • Legacy queued and restored CSV/JSON migrations with a composite resourceId still run through resolveResourceIds().
  • Pre-1.9.6 request formats can continue sending composite resourceId.
  • Pre-1.9.6 response formats receive the legacy composite shape with the new fields removed.
  • Single-root Appwrite and backup migrations retain root-only transfer semantics.

Validation

  • Full unit suite: 740 tests, 15,079 assertions
  • Appwrite database migration E2E: TablesDB/legacy, DocumentsDB, and VectorsDB; 3 tests, 112 assertions
  • CSV import plus list-by-database query E2E: 2 tests, 125 assertions
  • CSV export plus JSON import/export E2E: 3 tests, 215 assertions
  • CSV and JSON import E2E waits for asynchronous columns before enqueueing
  • Focused V25 and worker regressions: 6 tests, 97 assertions
  • Compatibility bridge uses fromResourceIds() and runWithResourceSelector() against migration#176 final green head
  • Prior feature-head CI run 29594880012: 37/37 jobs green, including MongoDB dedicated migrations
  • Current exact-head CI run 29614708739: 37/37 jobs passed for 7d0e4ba0f7d38f6cf15aeecbd31c8eb1060529f3, including MongoDB dedicated migrations
  • composer lint
  • composer analyze
  • composer refactor:check
  • composer audit --locked
  • CI-equivalent specs generation
  • Docker development image build

Linked

Merge note

The temporary exact commit pin keeps cross-PR CI reproducible. Replace it with the tagged Packagist release from utopia-php/migration#176 before merge.

@greptile-apps

greptile-apps Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR exposes migration resource links as separate queryable fields. The main changes are:

  • New source, parent, and destination resource fields on migration documents.
  • A V25 schema/data migration for legacy composite resource IDs.
  • CSV and JSON import/export endpoints that accept databaseId and collectionId separately.
  • V27 request and response filters for older SDK compatibility.
  • Worker updates for split resource IDs, selector handling, and completion hooks.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The latest changes address the reviewed compatibility and migration-backfill paths.

Important Files Changed

Filename Overview
src/Appwrite/Migration/Version/V25.php Adds the migration that creates new migration resource fields and backfills legacy composite IDs.
src/Appwrite/Platform/Workers/Migrations.php Updates migration worker source, destination, selector, completion, and stats handling for split resource IDs.
src/Appwrite/Utopia/Request/Filters/V27.php Adds request compatibility for legacy CSV and JSON migration payloads.
src/Appwrite/Utopia/Response/Filters/V27.php Adds response compatibility by recombining split migration resource fields for older clients.
app/config/collections/projects.php Adds nullable migration resource attributes and indexes for queryable migration links.
composer.json Temporarily points utopia-php/migration at the feature branch used by this PR.

Reviews (14): Last reviewed commit: "fix(migrations): normalize empty resourc..." | Re-trigger Greptile

Comment thread src/Appwrite/Utopia/Request/Filters/V25.php Outdated
Comment thread src/Appwrite/Migration/Version/V25.php Outdated
Comment thread src/Appwrite/Platform/Workers/Migrations.php Outdated
Comment thread src/Appwrite/Platform/Workers/Migrations.php
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

🔄 PHP-Retry Summary

Flaky tests detected across commits:

Commit 7f48a8a - 1 flaky test
Test Retries Total Time Details
LegacyCustomClientTest::testTimeout 1 139.25s Logs
Commit 4b5c123 - 1 flaky test
Test Retries Total Time Details
DocumentsDBCustomServerTest::testTimeout 1 128.35s Logs
Commit ea9a74b - 1 flaky test
Test Retries Total Time Details
DocumentsDBCustomServerTest::testTimeout 1 126.46s Logs
Commit 2d828af - 1 flaky test
Test Retries Total Time Details
FunctionsCustomServerTest::testDeleteExecution 1 149ms Logs
Commit 7d0e4ba - 1 flaky test
Test Retries Total Time Details
LegacyCustomClientTest::testNotEndsWith 1 240.89s Logs

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

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing 1.9.x (before) to feat/migration-resource-attrs (after).

Before

Scenario P50 (ms) P95 (ms) Requests RPS
API total 14.41 148.67 185 31.66
Account 30.9 169.19 35 6.64
TablesDB 13.38 21.41 35 7.7
Storage 12.54 150.65 75 16.18
Functions 24.54 35.65 40 8.7

After

Scenario P50 (ms) P95 (ms) Requests RPS
API total 14.69 150.6 185 31.66
Account 33.36 183.09 35 6.64
TablesDB 12.89 19.3 35 7.74
Storage 11.73 150.6 75 16.29
Functions 23.84 35.15 40 8.79

Delta

Scenario P95 delta (ms)
API total +1.92
Account +13.9
TablesDB -2.11
Storage -0.05
Functions -0.5
Top API waits
API request Max wait (ms)
account.sessions.email.create 586.75
account.create 182.92
account.password.update 167.24

Comment thread src/Appwrite/Utopia/Response/Filters/V25.php Outdated
@blacksmith-sh

blacksmith-sh Bot commented May 1, 2026

Copy link
Copy Markdown

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
› Tests\E2E\Services\TablesDB\TablesDBCustomClientTest/
testEnforceCollectionPermissions
View Logs

Fix in Cursor

Copilot AI review requested due to automatic review settings June 10, 2026 05:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ChiragAgg5k
ChiragAgg5k changed the base branch from 1.9.x to main June 23, 2026 09:53
@abnegate
abnegate force-pushed the feat/migration-resource-attrs branch from 7f48a8a to 2c02b5d Compare July 17, 2026 12:27
@abnegate abnegate changed the title refactor(migrations): split composite resourceId into parent/leaf feat(migrations): expose queryable resource links Jul 17, 2026
@abnegate
abnegate changed the base branch from main to 1.9.x July 17, 2026 12:27
@abnegate
abnegate force-pushed the feat/migration-resource-attrs branch from 2c02b5d to 4b5c123 Compare July 17, 2026 12:29
Comment thread src/Appwrite/Migration/Version/V25.php
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.

2 participants