diff --git a/src/Migration/Resources/Database/Columns/Relationship.php b/src/Migration/Resources/Database/Columns/Relationship.php index d0d3951d..b530c317 100644 --- a/src/Migration/Resources/Database/Columns/Relationship.php +++ b/src/Migration/Resources/Database/Columns/Relationship.php @@ -24,7 +24,7 @@ public function __construct( $key, $table, options: [ - 'relatedTable' => $relatedTable, + 'relatedCollection' => $relatedTable, 'relationType' => $relationType, 'twoWay' => $twoWay, 'twoWayKey' => $twoWayKey, diff --git a/src/Migration/Sources/Appwrite.php b/src/Migration/Sources/Appwrite.php index aa41fa65..d4e6a445 100644 --- a/src/Migration/Sources/Appwrite.php +++ b/src/Migration/Sources/Appwrite.php @@ -923,7 +923,7 @@ private function exportColumns(int $batchSize): void $col = new Relationship( $column['key'], $table, - relatedTable: $column['relatedCollection'], + relatedTable: $column['relatedTable'] ?? $column['relatedCollection'], relationType: $column['relationType'], twoWay: $column['twoWay'], twoWayKey: $column['twoWayKey'], @@ -998,13 +998,13 @@ private function exportIndexes(int $batchSize): void foreach ($response as $index) { $indexes[] = new Index( - 'unique()', + $index['$id'], $index['key'], $table, $index['type'], $index['columns'] ?? $index['attributes'], - [], - $index['orders'], + $index['lengths'] ?? [], + $index['orders'] ?? [], $index['$createdAt'] = empty($index['$createdAt']) ? UtopiaDateTime::now() : $index['$createdAt'], $index['$updatedAt'] = empty($index['$updatedAt']) ? UtopiaDateTime::now() : $index['$updatedAt'], ); diff --git a/src/Migration/Sources/Appwrite/Reader/API.php b/src/Migration/Sources/Appwrite/Reader/API.php index 97d70e24..da1a5022 100644 --- a/src/Migration/Sources/Appwrite/Reader/API.php +++ b/src/Migration/Sources/Appwrite/Reader/API.php @@ -74,16 +74,16 @@ public function report(array $resources, array &$report): mixed : [Query::limit($pageLimit)] )['collections']; /* ['tables'] */ - $tables = array_merge($tables, $currentTables); + $tables = \array_merge($tables, $currentTables); $lastTable = $tables[count($tables) - 1]['$id'] ?? null; - if (count($currentTables) < $pageLimit) { + if (\count($currentTables) < $pageLimit) { break; } } if (Resource::isSupported(Resource::TYPE_TABLE, $resources)) { - $report[Resource::TYPE_TABLE] += count($tables); + $report[Resource::TYPE_TABLE] += \count($tables); } if (Resource::isSupported([Resource::TYPE_ROW, Resource::TYPE_COLUMN, Resource::TYPE_INDEX], $resources)) { @@ -95,12 +95,11 @@ public function report(array $resources, array &$report): mixed $report[Resource::TYPE_COLUMN] += count($table['columns'] ?? $table['attributes'] ?? []); } - if (in_array(Resource::TYPE_INDEX, $resources)) { - // a table already returns a list of indexes - $report[Resource::TYPE_INDEX] += count($table['indexes'] ?? []); + if (\in_array(Resource::TYPE_INDEX, $resources)) { + // A table already returns a list of indexes + $report[Resource::TYPE_INDEX] += \count($table['indexes'] ?? []); } - // this one's a bit heavy if the number of tables are high! if (Resource::isSupported(Resource::TYPE_ROW, $resources)) { /* $rowsResponse = $this->tables->listRows(...) */ $rowsResponse = $this->database->listDocuments( diff --git a/src/Migration/Transfer.php b/src/Migration/Transfer.php index 67faa019..2a447eb4 100644 --- a/src/Migration/Transfer.php +++ b/src/Migration/Transfer.php @@ -40,11 +40,6 @@ class Transfer Resource::TYPE_INDEX, Resource::TYPE_COLUMN, Resource::TYPE_ROW, - - // legacy - Resource::TYPE_DOCUMENT, - Resource::TYPE_ATTRIBUTE, - Resource::TYPE_COLLECTION, ]; public const GROUP_SETTINGS_RESOURCES = []; @@ -142,7 +137,7 @@ public function getStatusCounters(): array foreach ($this->cache->getAll() as $resourceType => $resources) { foreach ($resources as $resource) { - if ($resourceType === Resource::TYPE_ROW && is_string($resource)) { + if (($resourceType === Resource::TYPE_ROW || $resourceType === Resource::TYPE_DOCUMENT) && is_string($resource)) { $rowStatus = $resource; $status[$resourceType][$rowStatus]++; @@ -286,7 +281,7 @@ public function getReport(string $statusLevel = ''): array foreach ($cache as $type => $resources) { foreach ($resources as $id => $resource) { - if ($type === Resource::TYPE_ROW && is_string($resource)) { + if (($type === Resource::TYPE_ROW || $type === Resource::TYPE_DOCUMENT) && is_string($resource)) { if ($statusLevel && $resource !== $statusLevel) { continue; }