Skip to content

chore: absorb migration into packages/migration - #14503

Merged
abnegate merged 1433 commits into
mainfrom
chore/absorb-migration
Oct 15, 2026
Merged

abnegate merged 1433 commits into
mainfrom
chore/absorb-migration

Conversation

@abnegate

Copy link
Copy Markdown
Member

Summary

Moves utopia-php/migration into packages/migration, so Appwrite loads it directly. This is section 2 of #14255 (wave 6 of #13828) and follows rfc/monorepo.md. The mirror head is c8b9ba5: the 3.1.2 release that Appwrite already locks, plus utopia-php/migration#229, the resolver and redirect controls merged today. That puts Appwrite on mirror head, as step 3 of the playbook requires.

# Commit What
1 Add 'packages/migration/' from commit 'c8b9ba5…' Subtree import from the mirror, with full history
2 chore(migration): mirror plumbing mirror.yml, README banner, and the mirror's workflows, pint.json and composer.lock removed
3 refactor: load migration from packages/ Step A, root wiring, PHPStan baseline, Rector, RFC entry
4 feat(migration): migrate what sdk-for-php 30.4 can write The one deliberate exception to a pure move (see below)
5 style(migration): strip trailing blank lines from .env.example One upstream file that failed git diff --check
6 fix(migration): run the e2e tier under the root toolchain Mounts packages/ for the toolchain autoloader; a mock with no expectations becomes a stub

Step A

Before After
Source src/Migration/*, Utopia\Migration\ → src/Migration src/*, Utopia\Migration\ → src/
Unit tier tests/Migration/Unit/*, Utopia\Tests\Unit\ tests/*, Utopia\Migration\Tests\
Services tier tests/Migration/E2E/* tests/E2E/, Utopia\Migration\Tests\E2E\ (Supabase and NHost from the package compose file)
Fixtures tests/Migration/resources tests/fixtures. tests/resources and the tests/Resources suite collide on case-insensitive filesystems
phpunit.xml E2E and Unit suites unit is tests minus tests/E2E and tests/fixtures; e2e is tests/E2E
phpstan.neon none (CLI level 3) standalone, level max over src and tests, scanning bin/MigrationCLI.php
rector.php none standalone, skipping src and tests until phase 8, as database does

The package also gets a few small fixes so it runs under the root packages suite and the standalone run alike:

  • The stalled-request fixture server takes its autoloader path from the test that starts it, instead of assuming the package's own vendor/.
  • bin/MigrationCLI.php loads the package autoloader only when one is installed.

E2E runs inside the compose network through tests/e2e.sh on appwrite/base:2.1.0, the same pattern as database. Three compose changes support it:

  • supabase-db and nhost-db gain pg_isready healthchecks, so docker compose up --wait covers their start-up. The mirror's CI used sleep 5.
  • The compose file now names its Dockerfile. absorb only keeps Dockerfiles that a dockerfile: key names, and it deleted this one.
  • The tests stage in that Dockerfile is gone, because the package no longer has a lock to install from.

utopia-php/dsn is dropped from require: nothing in the package uses it. #14255 had planned to bump it to ^1.0 instead.

sdk-for-php 30.4

Run against Packagist, the package resolves appwrite/appwrite 30.4.0. The mirror locked 30.2.2. AppwriteSdkCoverageTest exists to fail when the SDK can write something migration does not carry, and it flagged 11 items. Commit 4 migrates all of them from an Appwrite source to an Appwrite destination:

SDK Now
Teams::createMembership(membershipId) Memberships keep their source ID
Messaging::createTopic(qos, expiry) Topic carries both; the source reads them from the topic model
Messaging::createEmail(replyToEmail, replyToName) Scheduled emails pass them from the message data. Other messages already copy their data map whole
Messaging::createPush(channelId) Same, for scheduled pushes
updatePasswordPwnedPolicy, updatePasswordRotationPolicy Policies carries both, written to auths.passwordPwned and auths.passwordRotation like the other policies. A source that predates them leaves the destination's values in place
updatePasskeyPolicy Policies carries the relying party ID into auths.passkeyRpId. Passkeys are bound to the RP ID they were registered under, so while any user on the destination holds a passkey, the destination keeps its own RP ID. The policy endpoint enforces the same rule
createEnvironment, updateEnvironment A new project-environment resource (see below)

An environment is a Cloud feature: a separate project billed under its parent. Its ID is a project ID, unique across the platform, so on a Cloud-to-Cloud move the source usually still holds it. Each environment is therefore created under a new ID and matched by name on reruns. Its own resources belong to a different project and are not part of it. A host without the environments route (400 or 404) reports none as a source and skips them as a destination. MigrationReport gains the count.

To make these calls, the root appwrite/appwrite requirement moves from ^30.2.2 to ^30.4.0.

Lock

Package Before After
utopia-php/migration 3.1.2 removed
appwrite/appwrite 30.2.2 30.4.0

halaxa/json-machine moves into the root require at the version already locked. Nothing else in the lock changes.

Validation

Check Result
bin/monorepo validate all packages valid
bin/monorepo check migration Rector, Pint and PHPStan level max (with baseline) pass
bin/monorepo test migration (registry-resolved), unit tier 179 tests / 921 assertions
bin/monorepo test migration, e2e tier 22 tests / 84 assertions against the Supabase and NHost fixtures; no notices
phpunit --testsuite packages --filter 'Utopia\\Migration' under the root autoloader 179 tests / 921 assertions
Root PHPStan on the 16 Appwrite files that use Utopia\Migration no errors
composer validate --no-check-publish valid
bin/monorepo split migration --dry-run 6214295b, fast-forwards from the mirror head c8b9ba5
New behaviour AppwritePoliciesTest and two of its assertions fail with the policy writes or the passkey guard removed; AppwriteSdkCoverageTest fails against 30.4 without commit 4

Baseline: 1,716 findings. 1,453 are in src, nearly all arguments and offset access on the mixed SDK, REST and PDO results the sources read. 263 are in its tests. They are listed under phase 8 in the RFC.

Not verified: the full Appwrite e2e matrix on this branch. CI runs it.

Merge and follow-up

Merge with a merge commit (absorb label). A squash drops the git-subtree-* annotation and orphans the package from its mirror.

The absorb ran with --skip-ruleset. The mirror already has a main ruleset (id 18701583: no deletion, no force push, PRs required), but its bypass list has only the organization admin and repository role 5, not the split app 4016286. Split cannot push to the mirror until the app is added. Adding it is a repository settings change, so it is left to a maintainer:

bin/monorepo absorb migration

That command is idempotent on an existing package and normalises the ruleset to the canonical config.

After merging:

Step
Ruleset Add the split app's bypass (above)
Split Confirm Split pushes to utopia-php/migration
Cloud Drop its own utopia-php/migration requirement and take it through server-ce (#14255)
Triage The PRs still open on the mirror (below)
Mirror PR Opened Base Title
utopia-php/migration#240 2026-10 main feat: confine source requests to a destinations policy
utopia-php/migration#237 2026-10 2.0.x fix(csv): report rows that cannot be imported instead of changing or dropping them
utopia-php/migration#226 2026-09 main feat: report resources requested without their prerequisites
utopia-php/migration#205 2026-07 main Support duplicate handling for Appwrite imports
utopia-php/migration#200 2026-06 main fix: strip unknown internal attributes during migration
utopia-php/migration#199 2026-06 main Make Appwrite source report resilient to per-resource failures
utopia-php/migration#192 2026-05 main fix(nhost): correctly handle text column size for varchar vs text types
utopia-php/migration#189 2026-05 main Wrap user-facing throws in Sources/Appwrite as Migration\Exception
utopia-php/migration#182 2026-05 main chore(deps): bump appwrite/appwrite to 23.1.1
utopia-php/migration#172 2026-04 main fix: Handle missing 'database' key when migrating from Appwrite Cloud
utopia-php/migration#168 2026-04 main Add overwrite and skip options to Appwrite destination
utopia-php/migration#161, #160, #159, #157 2026-03 main CSV and duplicate-document fixes
utopia-php/migration#145 2026-03 main Add backup policy migration support
utopia-php/migration#133 2026-01 main Joins
utopia-php/migration#32 2024-06 main Add Appwrite Tests and Matrix the workflow

None of them is ported here. A PR that targets main and is still wanted gets reopened against packages/migration/src/, whose paths have lost the Migration/ segment. #237 targets 2.0.x, a version branch that stays on the mirror. The mirror also has two open issues, #88 and #64.

🤖 Generated with Claude Code

abnegate and others added 30 commits June 3, 2026 18:15
Replace the per-provider class hierarchy (OAuth2Provider base +
StandardProvider/WithEndpointProvider + ~40 one-line subclasses) with a
single OAuth2Provider class driven by a `providerKey => non-secret fields`
map. Addresses review feedback to have one class for all providers.

- Source dispatch: drop the 42-entry class registry + oauth2ClassFor();
  build providers via OAuth2Provider::fromArray($key, $payload).
- Destination dispatch: replace the instanceof chain with a key check
  (Apple) + data-driven settings routing for endpoint/tenant/prompt.
- The field map doubles as a secret allow-list: only declared non-secret
  fields are copied off the listOAuth2Providers payload, so a future
  upstream secret field cannot leak into the migration.

Net 44 fewer files. Pint, PHPStan level 3, and the Unit suite all pass.
- Remove unused getSetting(); getDestinationAppId/SecretFields cover all callers.
- getDestinationAppId() now returns ?string (null when unset), so the
  destination drops its duplicate isEmptyOAuth2Setting() helper and isConfigured()
  reads as `enabled || appId !== null`.
- Document the PROVIDERS target/key routing so adding a provider is self-explanatory.
getStatusCounters() seeds a status bucket only for requested resource
types and guards the non-row branch with isset(). The row/document branch
had no such guard: a row/document count aggregated into the cache for a
type that was not requested would auto-vivify $status[$type], read an
unseeded 'pending' key (emitting an "Undefined array key" warning) and
leave a phantom, non-empty entry that survives the empty-bucket prune.

Downstream this surfaced as a flaky assertEmpty($statusCounters) after an
otherwise clean migration. Add the same isset() guard the non-row branch
already uses so unrequested row/document counts are ignored.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
fix: ignore unrequested row/document types in status counters
Bump utopia-php/database to ^6.0.0 (drops the Swoole PDOProxy
dependency). Database 6.0 requires utopia-php/cache ^3.0, so the lock
modernizes accordingly; migration already runs against this dep set via
appwrite. No code changes — migration uses the high-level Database API.

Co-authored-by: Claude Opus 4.8 <[email protected]>
* read Appwrite table, attribute, and index metadata from the database-specific connection
* add regression coverage for split DocumentsDB report counts
…-metadata

Revert "Fix split database metadata reads"
…e-cascades

Fix Appwrite migration runtime cascades
@ghost

ghost commented Oct 15, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The fixture roles retain their permissions and attributes while the checked-in and regenerated dumps no longer expose role password hashes.

This PR absorbs utopia-php/migration into packages/migration, wires it into the root Composer setup, and documents its monorepo lifecycle. It adds migration support for Appwrite 30.4 fields and project environments, updates the migration report, and provides standalone analysis and unit/E2E test tooling. The latest commits remove PostgreSQL role password hashes from the Supabase fixture and prevent them from being included in refreshed dumps.

Latest changes: The latest commits replace the Supabase fixture's role password hashes with NULL and add --no-role-passwords to both fixture dump commands.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 8
File Change
composer.json, composer.lock Wire the absorbed package into root Composer autoloading and update the Appwrite SDK dependency.
packages/migration/src/ Move the migration library into the package and add support for the Appwrite 30.4 migration additions.
packages/migration/tests/ Add package unit and E2E coverage with Supabase and NHost fixtures; the latest commits scrub role hashes and omit passwords when refreshing dumps.
packages/migration/composer.json, packages/migration/phpstan.neon, packages/migration/phpunit.xml, packages/migration/rector.php, packages/migration/Dockerfile, packages/migration/docker-compose.yml Set up standalone package tooling and compose-backed E2E tests.
src/Appwrite/Utopia/Response/Model/MigrationReport.php Expose the project-environment migration count in migration reports.
rfc/monorepo.md Document migration as an absorbed monorepo package.
packages/migration/tests/fixtures/updateBackups.sh Refresh Supabase and NHost fixture dumps using the package-level environment configuration.
packages/migration/docker-compose.yml Configures the fixture databases and test container for package E2E runs, including TCP readiness checks.

Reviewed the commits since 1827cd0 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · See the inline comments. Summary

Comment thread packages/migration/README.md Resolved
Comment thread packages/migration/README.md Resolved
Comment thread packages/migration/bin/MigrationCLI.php Resolved
Comment thread packages/migration/bin/MigrationCLI.php Resolved
Comment thread packages/migration/docker-compose.yml Resolved
- The README example passes NHost its six constructor arguments, runs
  the transfer it creates, and uses the Local destination, which needs
  no database handles. The PHP requirement is 8.5, as the manifest says.
- .env.example uses the names bin/MigrationCLI.php reads, including the
  destination's project internal ID.
- The Postgres healthchecks connect over TCP: during initialisation the
  image's temporary server listens only on its socket, so a socket check
  passed before the fixtures had loaded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · See the inline comments. Summary

Comment thread packages/migration/.env.example Resolved
updateBackups.sh read the unprefixed SUPABASE_TEST_* and NHOST_TEST_*
names that .env.example no longer defines, sourced .env from a path the
move to tests/fixtures broke, and wrote a dump.sql nothing loads. It now
reads the SOURCE_*_TEST_* names the CLI uses, resolves .env from its own
directory, and writes the 1_globals.sql and 2_main.sql pair the fixture
databases load at start-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

pg_dumpall --globals-only writes each role's password hash, and the
fixture refresh commits its output, so the refresh now passes
--no-role-passwords. The Supabase globals fixture already carried seven
SCRAM hashes for the source project's internal roles; they become
PASSWORD NULL, which is what that flag writes. The e2e tier connects as
postgres, whose password the compose file sets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@abnegate
abnegate merged commit 636b49e into main Oct 15, 2026
223 checks passed
@abnegate
abnegate deleted the chore/absorb-migration branch October 15, 2026 06:00
This was referenced Oct 15, 2026
@ChiragAgg5k ChiragAgg5k mentioned this pull request Oct 21, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

absorb History-preserving package absorption; merge commit required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants