Skip to content
Open

Joins #133

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1d86a6b
Migration
fogelito Dec 22, 2025
ae04b11
Migration
fogelito Dec 22, 2025
98dd145
select
fogelito Dec 22, 2025
01e06cf
fallback query select
fogelito Dec 23, 2025
6a95abb
4.5.2
fogelito Jan 15, 2026
f2c5f6a
Merge branch 'main' of https://github.com/utopia-php/migration into j…
fogelito Jan 15, 2026
53ce92c
pull main
fogelito Jan 15, 2026
67c8eda
Merge branch 'main' of https://github.com/utopia-php/migration into j…
fogelito Jan 18, 2026
69ade1c
Update lock
fogelito Jan 18, 2026
066bd70
lock
fogelito Jan 18, 2026
49bddeb
database 4.5.2
fogelito Jan 18, 2026
f50c5ad
fix many2many
fogelito Jan 18, 2026
805bdb8
append queries
fogelito Jan 18, 2026
317e4c9
DB 4.6.2
fogelito Jan 28, 2026
bfafb18
lock
fogelito Jan 28, 2026
525ba8c
lock
fogelito Jan 28, 2026
bc73611
Merge branch 'main' of https://github.com/utopia-php/migration into j…
fogelito Jan 28, 2026
fb8378a
lock
fogelito Jan 28, 2026
fd6b9bc
SDK original
fogelito Jan 28, 2026
4030ff3
database 5.0
fogelito Feb 2, 2026
daa5f17
Merge branch 'main' of https://github.com/utopia-php/migration into j…
fogelito Feb 8, 2026
0a632aa
Update main
fogelito Feb 8, 2026
d115b61
Fix codeQL
fogelito Feb 8, 2026
9aeb2d5
Merge branch 'main' of https://github.com/utopia-php/migration into j…
fogelito Feb 11, 2026
ac60b6d
update main
fogelito Feb 11, 2026
4582154
Merge branch 'main' of https://github.com/utopia-php/migration into j…
fogelito Feb 18, 2026
db744ef
Update database 5.3.1
fogelito Feb 18, 2026
6817db3
Merge branch 'main' of https://github.com/utopia-php/migration into j…
fogelito Mar 2, 2026
b1c5095
Update lock
fogelito Mar 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ext-curl": "*",
"ext-openssl": "*",
"appwrite/appwrite": "19.*",
"utopia-php/database": "5.*",
"utopia-php/database": "dev-joins8 as 5.3.1",
"utopia-php/storage": "1.0.*",
"utopia-php/dsn": "0.2.*",
"halaxa/json-machine": "^1.2"
Expand Down
109 changes: 59 additions & 50 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Migration/Resources/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions src/Migration/Sources/Appwrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,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());
Expand All @@ -1275,22 +1280,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) {
Expand Down
5 changes: 3 additions & 2 deletions src/Migration/Sources/Appwrite/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Migration/Sources/Appwrite/Reader/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ public function getRow(Table $resource, string $rowId, array $queries = []): arr
}

/**
* @param array $columns
* @param string $column
* @return string
*/
public function querySelect(array $columns): string
public function querySelect(string $column): string
{
return Query::select($columns);
return Query::select([$column]);
}

/**
Expand Down
Loading