Repository navigation
chore: absorb utopia-php/mongo and utopia-php/database into packages/ - #14242
ChiragAgg5k wants to merge 6511 commits into
Conversation
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Mongo array dates
Mongo operators
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Operators binds
…max-param2 # Conflicts: # src/Database/Adapter/MariaDB.php
3.1.* excluded the 3.2.0 release (purge-tombstone lease, backward-compatible and opt-in). ^3.1 keeps the 3.1 floor the query/getDocument lease needs while accepting compatible minors, matching the ^3.0 constraint the rest of the ecosystem (server-ce, domains, vcs) already uses. Unblocks consumers that need cache 3.2.0. Co-Authored-By: Claude Opus 4.8 <[email protected]>
chore(deps): widen utopia-php/cache constraint to ^3.1 (accept 3.2.x)
…Unique SQLite::createIndex() let the PDOException escape unclassified, so a unique index over duplicate rows surfaced as a raw PDOException instead of UniqueException. It now goes through processException() like the other SQL adapters.
…ry adapter Each adapter must reject a unique index on a string or integer attribute whose rows already share a value with UniqueException, and leave the index out of the collection metadata.
…tion fix(indexes): fail unique index creation over duplicate rows
ST_Distance(a, b) < d cannot be served by a GIST index, so radius queries filtered every row while walking the primary key. Without meters, distanceLessThan now leads with ST_DWithin on the geometry column. With meters on a point column and a point value, it leads with a degree box (&& ST_Expand) that holds every point within range on the WGS84 spheroid. Lines and polygons, and boxes that would reach a pole or the antimeridian, keep the exact geography comparison only. The exact ST_Distance check stays in every case, so the boundary remains exclusive.
A document stored before an attribute became required holds null for it, and updates validate the merged document, so every update of that document failed with "Missing required attribute". When the current document already holds null, the attribute may stay null on update. Creating a document without it, or clearing a stored value, still fails.
Step A of the monorepo shape for both packages: flat src/, tests under Utopia\Mongo\Tests\ and Utopia\Database\Tests\ with the service suites in tests/E2E/, unit and e2e testsuites, level-max PHPStan with a baseline for the findings they arrived with, and a Rector config that leaves released code alone until the burn-down. Their e2e suites reach services by compose name, and database's stop and start containers by name, so tests/e2e.sh runs them inside the compose network on appwrite/base instead of the removed per-repository Dockerfiles. The suites were written for PHPUnit 9 and cache 5.0. Annotations become attributes, addMethods/withConsecutive/onConsecutiveCalls are replaced, and the cache test doubles accept save()'s $ttl, which otherwise fatals against cache 5.1.
Drops utopia-php/database 7.4.1 and utopia-php/mongo 1.5.4 from the lock; packages/ provides both through autoload and replace, which also satisfies migration's requirement on database. ramsey/uuid and ext-mongodb, which mongo and database required, are now root requirements. The rule that widens the e2e database matrix compared database's lock version; it now looks for packages/database/ or packages/mongo/ in the PR's files.
|
Review complete. No issues found — approved ✅. The diff for this PR is empty: no changed files were reported and the patch file is zero lines. No review findings were produced. Reviewed commit: 9928160 |
🟢 Tier S · Ready to merge
Imports Mongo and Database into Latest changes: The newest commit adds an
📂 Walkthrough · 12
Reviewed the commits since |
CI exports COMPOSE_FILE with the root override, which the packages do not have, so exec failed before any suite ran; the runners pin the package compose file as bin/monorepo does for up and down. mongo's Client uses Swoole's clients unconditionally, so it now declares ext-swoole, which is also what makes the package job install it. database's CONTRIBUTING points at bin/monorepo and tests/e2e.sh instead of the removed in-container setup.
# Conflicts: # composer.json # composer.lock
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
PHPUnit 10 and later reject instance data providers, so testInvalidDefaultValues errored on all 16 adapter suites under the root toolchain.
Connection::hasError() calls Swoole's DetectsLostConnections, which the extension's bundled library provides. The package job installs only the extensions a manifest names, so PHPStan there could not see the class; database now suggests ext-swoole, which the job reads.
|
Closing for now; this is scheduled for next week and tracked in #14255. The branch |
Summary
Wave 6 of #13828: moves
utopia-php/mongoandutopia-php/databaseintopackages/in one PR, because they share the MariaDB/PostgreSQL/MongoDB compose, following the playbook inrfc/monorepo.md.migrationcomes next in its own PR. After this, Appwrite's lock still vendors onlyutopia-php/migration.Six commits, plus review fixes and a merge of
main:Add 'packages/mongo/' from commit '34ccfd6…': subtree import of the mirror with its full history, at1.5.4, which Appwrite already locks.chore(mongo): mirror plumbing:mirror.yml, the README banner, the root-canonical QA files removed (pint.json,.coderabbit.yaml, the mirror's workflows), and the mirror ruleset with the split app as bypass.Add 'packages/database/' from commit '7b750be…': subtree import of the mirror'smain. That is7.4.1(locked here) plus one unreleased fix,c5fc677 fix(postgres): let distanceLessThan use the spatial index(fix(postgres): let distanceLessThan use the spatial index utopia-php/database#1001). Per the RFC's step 3, Appwrite runs that head from now on.chore(database): mirror plumbing: as for mongo, and also dropspsalm.xml,.gitpod.yml, the issue templates and the per-repositoryDockerfile.refactor(database): reshape mongo and database for packages/: step A for both.refactor: load mongo and database from packages/: root wiring, lock, CI rule and RFC.Step A (commit 5)
database:src/Database/*→src/;tests/unit/*→tests/,tests/e2e→tests/E2E; tests move fromTests\Unit\/Tests\E2E\toUtopia\Database\Tests\/Utopia\Database\Tests\E2E\.mongo: tests move fromUtopia\Tests\toUtopia\Mongo\Tests\;MongoTestandTransactionTest, which need a live server, move totests/E2E.phpunit.xmlin each now hasunitande2esuites.src/is byte-for-byte the import.git diffbetween the subtree import andHEADis empty for both packages'src, including whitespace; Pint changes nothing there.database'sGeneralTestsalso stop and start containers by name to exercise the cache/mirror failover. Rather than rewrite them for the host,tests/e2e.sh(composer test:e2e) runs them inside the compose network.testsservice now usesappwrite/base:2.1.0(PHP 8.5 withpdo_mysql,pdo_pgsql,pdo_sqlite,mongodb,redis,swooleand the Docker CLI). It mounts the package (withvendor/already installed bybin/monorepo test), the root toolchain'svendor/forphpunit, and, fordatabase, the Docker socket. This replaces the per-repository Dockerfiles that compiled those extensions.database's Adminer and mongo-express move to adebugprofile.database'stest:e2edisables Composer's process timeout, as its oldtestscript did: the tier is 10,708 tests.packages/cachethey fataled or errored, so the tests (notsrc) change as follows:@depends/@dataProvider/@testdocblocks → attributes: 95 in total, including the scope traits, which Rector's set skips.addMethods(['inTransaction'])→ stub the wrapper's__call.withConsecutive→ record the executed statements and assert them in order.onConsecutiveCalls(throwException(…), …)→ a counting callback.DateTimeTestsets its fixtures insetUp(), sinceTestCase::__constructis final in PHPUnit 12.invalidDefaultValuesbecomes a static data provider.HashAwareMemoryCache,HashMemoryCache,JsonHashMemoryCache,LeasableMemoryCache) acceptsave()'sint $ttl = 0. Without it they fatal against cache 5.1.x even when resolved from Packagist, so this was already broken on the mirror for anything newer than the 5.0.0 it locked.phpstan.neonat level max, with baselines for what the packages arrived with:database: 4,865 findings, 2,348 insrc(752 inDatabase.php) and 2,517 in the tests. It had only Psalm before.mongo: 420 findings. Its own repository ran level 5.mongo'stests/ClientTest.phpis excluded: its transport doubles narrow the parameters of Swoole client methods that the stubs type asmixed, which PHPStan reports as non-ignorable.rector.phpthat skips both packages'srcandtests. Run as-is it rewrites released code (types added,isset()turned into=== null, docblocks removed). Absorbing moves code, so that waits for the burn-down.Root wiring (commit 6)
bin/monorepo autoloadadds both packages to the root autoload,autoload-devandreplace."utopia-php/database": "^7.4.1"leavesrequire.replacealso satisfies the still-vendoredmigration's requirement ondatabase.require:ramsey/uuid: 4.9.*(mongo's) andext-mongodb: *(both packages'; Appwrite only had it transitively). No other third-party requirement needed hoisting.utopia-php/database 7.4.1andutopia-php/mongo 1.5.4, nothing else.ramsey/uuidstays at 4.9.4.utopia-php/database's lock version changed. It now widens when the PR's files touchpackages/database/orpackages/mongo/, as the RFC planned. TheTests / Matrixjob gainspull-requests: readfor that. This PR itself therefore runs the full matrix.rfc/monorepo.md: phase 5 notes and both baselines.Review and CI fixes after opening
COMPOSE_FILE=docker-compose.yml, because CI exports the root override andexecfailed before any suite ran;mongorequiresext-swoole, becauseClientconstructs Swoole's clients unconditionally;database's CONTRIBUTING points atbin/monorepoandtests/e2e.sh.invalidDefaultValuesbecomes a static data provider. PHPUnit 10+ rejects instance providers, so 16 adapter suites errored.databasesuggestsext-swoole.Connection::hasError()calls Swoole'sDetectsLostConnections, which the extension's bundled library provides; the package job installs only the extensions a manifest names, so PHPStan there could not see the class.Packages / database(477 unit tests plus the 11,092-test e2e tier in about 42 minutes).MariaDB (shared) / Account(testUpdateAccountEmailSearch) andMongoDB (shared) / Realtime(testIndexesTablesAPI) each failed once. Both passed on the next run without changes.MongoDB (dedicated) / Functionsfailed pulling its image, andPackages / confighit a Rector worker crash ("Child process error", no finding). Both passed on rerun.Validation
bin/monorepo validate: all packages valid.bin/monorepo check mongoandbin/monorepo check database: Rector, Pint and PHPStan level max (with baselines) pass.bin/monorepo test mongo: unit tier 35 tests; e2e tier (in the compose network) 27 tests, all passing.bin/monorepo test database:invalidDefaultValues), which PHPUnit 10+ rejects; 3869d5d fixes it, and a rerun of the affected tests passes on all 16 adapter suites (448 tests).testKeywordsruns are risky (no assertions on that adapter), as released.packagessuite filtered toUtopia\(Database|Mongo), inappwrite/base:2.1.0: 512 tests pass.unitsuite inappwrite/base:2.1.0with.env: 1,406 tests pass.composer lint,composer refactor:checkandcomposer analyzepass.bin/monorepo split mongo --dry-run→66b3afcandsplit database --dry-run→2caf9b0; both fast-forward from the mirror heads.git diff --checkreports trailing whitespace only in imported files:database's README, CONTRIBUTING and docs (Markdown hard breaks) and SQL strings insidesrc. These are kept as released; nothing new adds whitespace.Open issues and PRs on the mirrors, for triage after merge
mirror-redirectcloses anything new; these predate the move.utopia-php/mongo (3 PRs, 2 issues). All three PRs carry live ideas and would need re-opening against
packages/mongo:upsertWithCounts();BulkWriteExceptionwith write results.Issues #45 (retryable writes outside transactions) and #39 (handshake client metadata) are feature requests to carry over.
utopia-php/database (56 PRs, 4 issues):
statement_timeout,utf8_ci_aicollation for_uid,INSERT … RETURNING,_permswrites, GIN fulltext,?|role check, cache for non-relationshipgetDocument, pool getters without checkout, redundant rollback);OnDuplicate, Feat new public permissions #823 use the query lib, Feat update packges links #763 joins.createCollectionclaim) and feat-utopia-image-integration #923 (Mongo_uidcollation forcing COLLSCAN) are live bugs. Add blurha support for image #328 (DynamoDB) and Fixed Grammer and Typos #94 (getIntLimit()not enforced) are old.Merge and follow-up
Merge with a merge commit. A squash drops the
git-subtree-*annotations and orphans both packages from their mirrors.After merge:
Splitpushes toutopia-php/mongoandutopia-php/database, and that each mirror's tree matchespackages/<name>.migration(wave 6, second PR).Related: #13828
Related: #14255