diff --git a/composer.json b/composer.json index 806fedb..6b6f3fe 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "ext-curl": "*", "ext-openssl": "*", "appwrite/appwrite": "19.*", - "utopia-php/database": "4.*", + "utopia-php/database": "dev-joins8 as 4.6.2", "utopia-php/storage": "0.18.*", "utopia-php/dsn": "0.2.*", "utopia-php/console": "0.0.*", diff --git a/composer.lock b/composer.lock index 48cd96b..2c67403 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5bece3d3d0a709fd79f03912b6b5ab6d", + "content-hash": "865a703709d41bc8ac3dc8ad4821362f", "packages": [ { "name": "appwrite/appwrite", @@ -514,16 +514,16 @@ }, { "name": "open-telemetry/api", - "version": "1.7.1", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/api.git", - "reference": "45bda7efa8fcdd9bdb0daa2f26c8e31f062f49d4" + "reference": "df5197c6fd0ddd8e9883b87de042d9341300e2ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/45bda7efa8fcdd9bdb0daa2f26c8e31f062f49d4", - "reference": "45bda7efa8fcdd9bdb0daa2f26c8e31f062f49d4", + "url": "https://api.github.com/repos/opentelemetry-php/api/zipball/df5197c6fd0ddd8e9883b87de042d9341300e2ad", + "reference": "df5197c6fd0ddd8e9883b87de042d9341300e2ad", "shasum": "" }, "require": { @@ -533,7 +533,7 @@ "symfony/polyfill-php82": "^1.26" }, "conflict": { - "open-telemetry/sdk": "<=1.0.8" + "open-telemetry/sdk": "<=1.11" }, "type": "library", "extra": { @@ -580,7 +580,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2025-10-19T10:49:48+00:00" + "time": "2026-01-21T04:14:03+00:00" }, { "name": "open-telemetry/context", @@ -770,16 +770,16 @@ }, { "name": "open-telemetry/sdk", - "version": "1.10.0", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/sdk.git", - "reference": "3dfc3d1ad729ec7eb25f1b9a4ae39fe779affa99" + "reference": "7f1bd524465c1ca42755a9ef1143ba09913f5be0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/3dfc3d1ad729ec7eb25f1b9a4ae39fe779affa99", - "reference": "3dfc3d1ad729ec7eb25f1b9a4ae39fe779affa99", + "url": "https://api.github.com/repos/opentelemetry-php/sdk/zipball/7f1bd524465c1ca42755a9ef1143ba09913f5be0", + "reference": "7f1bd524465c1ca42755a9ef1143ba09913f5be0", "shasum": "" }, "require": { @@ -820,7 +820,7 @@ ] }, "branch-alias": { - "dev-main": "1.9.x-dev" + "dev-main": "1.12.x-dev" } }, "autoload": { @@ -863,20 +863,20 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2025-11-25T10:59:15+00:00" + "time": "2026-01-21T04:14:03+00:00" }, { "name": "open-telemetry/sem-conv", - "version": "1.37.0", + "version": "1.38.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/sem-conv.git", - "reference": "8da7ec497c881e39afa6657d72586e27efbd29a1" + "reference": "e613bc640a407def4991b8a936a9b27edd9a3240" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/sem-conv/zipball/8da7ec497c881e39afa6657d72586e27efbd29a1", - "reference": "8da7ec497c881e39afa6657d72586e27efbd29a1", + "url": "https://api.github.com/repos/opentelemetry-php/sem-conv/zipball/e613bc640a407def4991b8a936a9b27edd9a3240", + "reference": "e613bc640a407def4991b8a936a9b27edd9a3240", "shasum": "" }, "require": { @@ -916,11 +916,11 @@ ], "support": { "chat": "https://app.slack.com/client/T08PSQ7BQ/C01NFPCV44V", - "docs": "https://opentelemetry.io/docs/php", + "docs": "https://opentelemetry.io/docs/languages/php", "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2025-09-03T12:08:10+00:00" + "time": "2026-01-21T04:14:03+00:00" }, { "name": "php-http/discovery", @@ -1487,16 +1487,16 @@ }, { "name": "symfony/http-client", - "version": "v7.4.3", + "version": "v7.4.4", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "d01dfac1e0dc99f18da48b18101c23ce57929616" + "reference": "d63c23357d74715a589454c141c843f0172bec6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/d01dfac1e0dc99f18da48b18101c23ce57929616", - "reference": "d01dfac1e0dc99f18da48b18101c23ce57929616", + "url": "https://api.github.com/repos/symfony/http-client/zipball/d63c23357d74715a589454c141c843f0172bec6c", + "reference": "d63c23357d74715a589454c141c843f0172bec6c", "shasum": "" }, "require": { @@ -1564,7 +1564,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.4.3" + "source": "https://github.com/symfony/http-client/tree/v7.4.4" }, "funding": [ { @@ -1584,7 +1584,7 @@ "type": "tidelift" } ], - "time": "2025-12-23T14:50:43+00:00" + "time": "2026-01-23T16:34:22+00:00" }, { "name": "symfony/http-client-contracts", @@ -2130,16 +2130,16 @@ }, { "name": "utopia-php/cache", - "version": "0.13.3", + "version": "0.13.2", "source": { "type": "git", "url": "https://github.com/utopia-php/cache.git", - "reference": "355707ab2c0090435059216165db86976b68a126" + "reference": "5768498c9f451482f0bf3eede4d6452ddcd4a0f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/cache/zipball/355707ab2c0090435059216165db86976b68a126", - "reference": "355707ab2c0090435059216165db86976b68a126", + "url": "https://api.github.com/repos/utopia-php/cache/zipball/5768498c9f451482f0bf3eede4d6452ddcd4a0f6", + "reference": "5768498c9f451482f0bf3eede4d6452ddcd4a0f6", "shasum": "" }, "require": { @@ -2147,7 +2147,7 @@ "ext-memcached": "*", "ext-redis": "*", "php": ">=8.0", - "utopia-php/pools": "1.*", + "utopia-php/pools": "0.8.*", "utopia-php/telemetry": "*" }, "require-dev": { @@ -2176,9 +2176,9 @@ ], "support": { "issues": "https://github.com/utopia-php/cache/issues", - "source": "https://github.com/utopia-php/cache/tree/0.13.3" + "source": "https://github.com/utopia-php/cache/tree/0.13.2" }, - "time": "2026-01-16T07:54:34+00:00" + "time": "2025-12-17T08:55:43+00:00" }, { "name": "utopia-php/compression", @@ -2276,16 +2276,16 @@ }, { "name": "utopia-php/database", - "version": "4.5.3", + "version": "dev-joins8", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "78f7c97e12872b206c4ee6bc8cdc342654b7568c" + "reference": "9623b153095b133f50a7472dc89d9ca4988afdde" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/78f7c97e12872b206c4ee6bc8cdc342654b7568c", - "reference": "78f7c97e12872b206c4ee6bc8cdc342654b7568c", + "url": "https://api.github.com/repos/utopia-php/database/zipball/9623b153095b133f50a7472dc89d9ca4988afdde", + "reference": "9623b153095b133f50a7472dc89d9ca4988afdde", "shasum": "" }, "require": { @@ -2296,7 +2296,7 @@ "utopia-php/cache": "0.13.*", "utopia-php/framework": "0.33.*", "utopia-php/mongo": "0.11.*", - "utopia-php/pools": "1.*" + "utopia-php/pools": "0.8.*" }, "require-dev": { "fakerphp/faker": "1.23.*", @@ -2328,9 +2328,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/4.5.3" + "source": "https://github.com/utopia-php/database/tree/joins8" }, - "time": "2026-01-16T08:45:47+00:00" + "time": "2026-01-28T08:28:53+00:00" }, { "name": "utopia-php/dsn", @@ -2488,16 +2488,16 @@ }, { "name": "utopia-php/pools", - "version": "1.0.0", + "version": "0.8.3", "source": { "type": "git", "url": "https://github.com/utopia-php/pools.git", - "reference": "74ba7dc985c2f629df8cf08ed95507955e3bcf86" + "reference": "ad7d6ba946376e81c603204285ce9a674b6502b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/pools/zipball/74ba7dc985c2f629df8cf08ed95507955e3bcf86", - "reference": "74ba7dc985c2f629df8cf08ed95507955e3bcf86", + "url": "https://api.github.com/repos/utopia-php/pools/zipball/ad7d6ba946376e81c603204285ce9a674b6502b8", + "reference": "ad7d6ba946376e81c603204285ce9a674b6502b8", "shasum": "" }, "require": { @@ -2507,8 +2507,7 @@ "require-dev": { "laravel/pint": "1.*", "phpstan/phpstan": "1.*", - "phpunit/phpunit": "11.*", - "swoole/ide-helper": "5.1.2" + "phpunit/phpunit": "11.*" }, "type": "library", "autoload": { @@ -2535,22 +2534,22 @@ ], "support": { "issues": "https://github.com/utopia-php/pools/issues", - "source": "https://github.com/utopia-php/pools/tree/1.0.0" + "source": "https://github.com/utopia-php/pools/tree/0.8.3" }, - "time": "2026-01-15T12:34:17+00:00" + "time": "2025-12-17T09:35:18+00:00" }, { "name": "utopia-php/storage", - "version": "0.18.21", + "version": "0.18.22", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "cabf77fb9cce98ff3629f341cde05b88e5598f93" + "reference": "c46bd78c1f52281df89f8921159782b20260ce31" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/cabf77fb9cce98ff3629f341cde05b88e5598f93", - "reference": "cabf77fb9cce98ff3629f341cde05b88e5598f93", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/c46bd78c1f52281df89f8921159782b20260ce31", + "reference": "c46bd78c1f52281df89f8921159782b20260ce31", "shasum": "" }, "require": { @@ -2593,22 +2592,22 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.18.21" + "source": "https://github.com/utopia-php/storage/tree/0.18.22" }, - "time": "2026-01-01T19:12:11+00:00" + "time": "2026-01-15T01:36:39+00:00" }, { "name": "utopia-php/system", - "version": "0.9.0", + "version": "0.10.0", "source": { "type": "git", "url": "https://github.com/utopia-php/system.git", - "reference": "8e4a7edaf2dfeb4c9524e9f766d27754f2c4b64d" + "reference": "6441a9c180958a373e5ddb330264dd638539dfdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/system/zipball/8e4a7edaf2dfeb4c9524e9f766d27754f2c4b64d", - "reference": "8e4a7edaf2dfeb4c9524e9f766d27754f2c4b64d", + "url": "https://api.github.com/repos/utopia-php/system/zipball/6441a9c180958a373e5ddb330264dd638539dfdb", + "reference": "6441a9c180958a373e5ddb330264dd638539dfdb", "shasum": "" }, "require": { @@ -2616,7 +2615,7 @@ }, "require-dev": { "laravel/pint": "1.13.*", - "phpstan/phpstan": "1.10.*", + "phpstan/phpstan": "1.12.*", "phpunit/phpunit": "9.6.*" }, "type": "library", @@ -2649,9 +2648,9 @@ ], "support": { "issues": "https://github.com/utopia-php/system/issues", - "source": "https://github.com/utopia-php/system/tree/0.9.0" + "source": "https://github.com/utopia-php/system/tree/0.10.0" }, - "time": "2024-10-09T14:44:01+00:00" + "time": "2025-10-15T19:12:00+00:00" }, { "name": "utopia-php/telemetry", @@ -3585,16 +3584,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.46", + "version": "11.5.50", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "75dfe79a2aa30085b7132bb84377c24062193f33" + "reference": "fdfc727f0fcacfeb8fcb30c7e5da173125b58be3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/75dfe79a2aa30085b7132bb84377c24062193f33", - "reference": "75dfe79a2aa30085b7132bb84377c24062193f33", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fdfc727f0fcacfeb8fcb30c7e5da173125b58be3", + "reference": "fdfc727f0fcacfeb8fcb30c7e5da173125b58be3", "shasum": "" }, "require": { @@ -3608,14 +3607,14 @@ "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.2", - "phpunit/php-code-coverage": "^11.0.11", + "phpunit/php-code-coverage": "^11.0.12", "phpunit/php-file-iterator": "^5.1.0", "phpunit/php-invoker": "^5.0.1", "phpunit/php-text-template": "^4.0.1", "phpunit/php-timer": "^7.0.1", "sebastian/cli-parser": "^3.0.2", "sebastian/code-unit": "^3.0.3", - "sebastian/comparator": "^6.3.2", + "sebastian/comparator": "^6.3.3", "sebastian/diff": "^6.0.2", "sebastian/environment": "^7.2.1", "sebastian/exporter": "^6.3.2", @@ -3666,7 +3665,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.46" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.50" }, "funding": [ { @@ -3690,7 +3689,7 @@ "type": "tidelift" } ], - "time": "2025-12-06T08:01:15+00:00" + "time": "2026-01-27T05:59:18+00:00" }, { "name": "sebastian/cli-parser", @@ -3864,16 +3863,16 @@ }, { "name": "sebastian/comparator", - "version": "6.3.2", + "version": "6.3.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "85c77556683e6eee4323e4c5468641ca0237e2e8" + "reference": "2c95e1e86cb8dd41beb8d502057d1081ccc8eca9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/85c77556683e6eee4323e4c5468641ca0237e2e8", - "reference": "85c77556683e6eee4323e4c5468641ca0237e2e8", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2c95e1e86cb8dd41beb8d502057d1081ccc8eca9", + "reference": "2c95e1e86cb8dd41beb8d502057d1081ccc8eca9", "shasum": "" }, "require": { @@ -3932,7 +3931,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.2" + "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.3" }, "funding": [ { @@ -3952,7 +3951,7 @@ "type": "tidelift" } ], - "time": "2025-08-10T08:07:46+00:00" + "time": "2026-01-24T09:26:40+00:00" }, { "name": "sebastian/complexity", @@ -5032,9 +5031,18 @@ "time": "2025-12-27T19:49:13+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-joins8", + "alias": "4.6.2", + "alias_normalized": "4.6.2.0" + } + ], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Migration/Resources/Database/Database.php b/src/Migration/Resources/Database/Database.php index 06882b2..8a911c4 100644 --- a/src/Migration/Resources/Database/Database.php +++ b/src/Migration/Resources/Database/Database.php @@ -38,6 +38,7 @@ public function __construct( * updatedAt: string, * enabled: bool, * originalId: string|null, + * type: string|null, * } $array */ public static function fromArray(array $array): self diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index d4b16d9..f0c722f 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -1119,6 +1119,11 @@ private function exportRows(int $batchSize): void } $selects = ['*', '$id', '$permissions', '$updatedAt', '$createdAt']; // We want relations flat! + + foreach ($selects as $select) { + $queries[] = $this->database->querySelect($select); + } + $manyToMany = []; $attributes = $this->cache->get(Column::getName()); @@ -1142,22 +1147,22 @@ private function exportRows(int $batchSize): void } /** @var Column|Relationship $attribute */ - $queries[] = $this->database->querySelect($selects); - $response = $this->database->listRows($table, $queries); foreach ($response as $row) { // HACK: Handle many to many if (!empty($manyToMany)) { - $stack = ['$id']; // Adding $id because we can't select only relations + $queries = []; + $queries[] = $this->database->querySelect('$id'); // Adding $id because we can't select only relations + foreach ($manyToMany as $relation) { - $stack[] = $relation . '.$id'; + $queries[] = $this->database->querySelect($relation . '.$id'); } $rowItem = $this->database->getRow( $table, $row['$id'], - [$this->database->querySelect($stack)] + $queries ); foreach ($manyToMany as $key) { diff --git a/src/Migration/Sources/Appwrite/Reader.php b/src/Migration/Sources/Appwrite/Reader.php index 314d4c3..90645c8 100644 --- a/src/Migration/Sources/Appwrite/Reader.php +++ b/src/Migration/Sources/Appwrite/Reader.php @@ -2,6 +2,7 @@ namespace Utopia\Migration\Sources\Appwrite; +use Utopia\Database\Query; use Utopia\Migration\Resource; use Utopia\Migration\Resources\Database\Database; use Utopia\Migration\Resources\Database\Table; @@ -78,10 +79,10 @@ public function getRow(Table $resource, string $rowId, array $queries = []): arr /** * Return a query to select the given attributes * - * @param array $columns + * @param string $column * @return QueryType|string */ - public function querySelect(array $columns): mixed; + public function querySelect(string $column): mixed; /** * Return a query to filter the given attributes diff --git a/src/Migration/Sources/Appwrite/Reader/API.php b/src/Migration/Sources/Appwrite/Reader/API.php index 388a0ce..e740340 100644 --- a/src/Migration/Sources/Appwrite/Reader/API.php +++ b/src/Migration/Sources/Appwrite/Reader/API.php @@ -212,12 +212,19 @@ public function getRow(Table $resource, string $rowId, array $queries = []): arr } /** - * @param array $columns - * @return string + * @param string $column + * @return Query */ - public function querySelect(array $columns): string + public function querySelect(string $column): string { - return Query::select($columns); + return Query::select([$column]); + + return new Query('select', $column); + + /** + * todo fix Query::select to get attribute not array + */ + return Query::select($column); } /** diff --git a/src/Migration/Sources/Appwrite/Reader/Database.php b/src/Migration/Sources/Appwrite/Reader/Database.php index bad744c..234b42a 100644 --- a/src/Migration/Sources/Appwrite/Reader/Database.php +++ b/src/Migration/Sources/Appwrite/Reader/Database.php @@ -360,12 +360,12 @@ public function getRow(TableResource $resource, string $rowId, array $queries = } /** - * @param array $columns + * @param string $column * @return Query */ - public function querySelect(array $columns): Query + public function querySelect(string $column): Query { - return Query::select($columns); + return Query::select($column); } /**