diff --git a/composer.json b/composer.json index 4cefc3d..0c6333e 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.5.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 fb29c8a..82eb657 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": "cf3cc5c8ea77349cef37794a3a47f45e", + "content-hash": "340b05ddc60cf89b2496bd2817f1ab84", "packages": [ { "name": "appwrite/appwrite", @@ -708,16 +708,16 @@ }, { "name": "open-telemetry/sdk", - "version": "1.10.0", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/sdk.git", - "reference": "3dfc3d1ad729ec7eb25f1b9a4ae39fe779affa99" + "reference": "d91f21addcdb42da9a451c002777f8318432461a" }, "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/d91f21addcdb42da9a451c002777f8318432461a", + "reference": "d91f21addcdb42da9a451c002777f8318432461a", "shasum": "" }, "require": { @@ -801,7 +801,7 @@ "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-15T11:21:03+00:00" }, { "name": "open-telemetry/sem-conv", @@ -2068,16 +2068,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": { @@ -2085,7 +2085,7 @@ "ext-memcached": "*", "ext-redis": "*", "php": ">=8.0", - "utopia-php/pools": "1.*", + "utopia-php/pools": "0.8.*", "utopia-php/telemetry": "*" }, "require-dev": { @@ -2114,9 +2114,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", @@ -2214,16 +2214,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": "8d35f5cbfda7496d136a73cae45ff87c54536ec3" }, "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/8d35f5cbfda7496d136a73cae45ff87c54536ec3", + "reference": "8d35f5cbfda7496d136a73cae45ff87c54536ec3", "shasum": "" }, "require": { @@ -2234,7 +2234,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.*", @@ -2266,9 +2266,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-18T08:00:42+00:00" }, { "name": "utopia-php/dsn", @@ -2426,16 +2426,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": { @@ -2445,8 +2445,7 @@ "require-dev": { "laravel/pint": "1.*", "phpstan/phpstan": "1.*", - "phpunit/phpunit": "11.*", - "swoole/ide-helper": "5.1.2" + "phpunit/phpunit": "11.*" }, "type": "library", "autoload": { @@ -2473,22 +2472,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": { @@ -2531,9 +2530,9 @@ ], "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", @@ -3523,16 +3522,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.46", + "version": "11.5.48", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "75dfe79a2aa30085b7132bb84377c24062193f33" + "reference": "fe3665c15e37140f55aaf658c81a2eb9030b6d89" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/75dfe79a2aa30085b7132bb84377c24062193f33", - "reference": "75dfe79a2aa30085b7132bb84377c24062193f33", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fe3665c15e37140f55aaf658c81a2eb9030b6d89", + "reference": "fe3665c15e37140f55aaf658c81a2eb9030b6d89", "shasum": "" }, "require": { @@ -3546,7 +3545,7 @@ "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", @@ -3604,7 +3603,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.48" }, "funding": [ { @@ -3628,7 +3627,7 @@ "type": "tidelift" } ], - "time": "2025-12-06T08:01:15+00:00" + "time": "2026-01-16T16:26:27+00:00" }, { "name": "sebastian/cli-parser", @@ -4970,9 +4969,18 @@ "time": "2025-12-27T19:49:13+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-joins8", + "alias": "4.5.2", + "alias_normalized": "4.5.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..b36b85b 100644 --- a/src/Migration/Sources/Appwrite/Reader/API.php +++ b/src/Migration/Sources/Appwrite/Reader/API.php @@ -212,12 +212,17 @@ 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 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); } /**