Skip to content

Commit cf6b192

Browse files
authored
Merge pull request #95 from utopia-php/fix-groups
Fix new terminology
2 parents 9f42837 + 65399a1 commit cf6b192

4 files changed

Lines changed: 13 additions & 19 deletions

File tree

src/Migration/Resources/Database/Columns/Relationship.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(
2424
$key,
2525
$table,
2626
options: [
27-
'relatedTable' => $relatedTable,
27+
'relatedCollection' => $relatedTable,
2828
'relationType' => $relationType,
2929
'twoWay' => $twoWay,
3030
'twoWayKey' => $twoWayKey,

src/Migration/Sources/Appwrite.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ private function exportColumns(int $batchSize): void
923923
$col = new Relationship(
924924
$column['key'],
925925
$table,
926-
relatedTable: $column['relatedCollection'],
926+
relatedTable: $column['relatedTable'] ?? $column['relatedCollection'],
927927
relationType: $column['relationType'],
928928
twoWay: $column['twoWay'],
929929
twoWayKey: $column['twoWayKey'],
@@ -998,13 +998,13 @@ private function exportIndexes(int $batchSize): void
998998

999999
foreach ($response as $index) {
10001000
$indexes[] = new Index(
1001-
'unique()',
1001+
$index['$id'],
10021002
$index['key'],
10031003
$table,
10041004
$index['type'],
10051005
$index['columns'] ?? $index['attributes'],
1006-
[],
1007-
$index['orders'],
1006+
$index['lengths'] ?? [],
1007+
$index['orders'] ?? [],
10081008
$index['$createdAt'] = empty($index['$createdAt']) ? UtopiaDateTime::now() : $index['$createdAt'],
10091009
$index['$updatedAt'] = empty($index['$updatedAt']) ? UtopiaDateTime::now() : $index['$updatedAt'],
10101010
);

src/Migration/Sources/Appwrite/Reader/API.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ public function report(array $resources, array &$report): mixed
7474
: [Query::limit($pageLimit)]
7575
)['collections']; /* ['tables'] */
7676

77-
$tables = array_merge($tables, $currentTables);
77+
$tables = \array_merge($tables, $currentTables);
7878
$lastTable = $tables[count($tables) - 1]['$id'] ?? null;
7979

80-
if (count($currentTables) < $pageLimit) {
80+
if (\count($currentTables) < $pageLimit) {
8181
break;
8282
}
8383
}
8484

8585
if (Resource::isSupported(Resource::TYPE_TABLE, $resources)) {
86-
$report[Resource::TYPE_TABLE] += count($tables);
86+
$report[Resource::TYPE_TABLE] += \count($tables);
8787
}
8888

8989
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
9595
$report[Resource::TYPE_COLUMN] += count($table['columns'] ?? $table['attributes'] ?? []);
9696
}
9797

98-
if (in_array(Resource::TYPE_INDEX, $resources)) {
99-
// a table already returns a list of indexes
100-
$report[Resource::TYPE_INDEX] += count($table['indexes'] ?? []);
98+
if (\in_array(Resource::TYPE_INDEX, $resources)) {
99+
// A table already returns a list of indexes
100+
$report[Resource::TYPE_INDEX] += \count($table['indexes'] ?? []);
101101
}
102102

103-
// this one's a bit heavy if the number of tables are high!
104103
if (Resource::isSupported(Resource::TYPE_ROW, $resources)) {
105104
/* $rowsResponse = $this->tables->listRows(...) */
106105
$rowsResponse = $this->database->listDocuments(

src/Migration/Transfer.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ class Transfer
4040
Resource::TYPE_INDEX,
4141
Resource::TYPE_COLUMN,
4242
Resource::TYPE_ROW,
43-
44-
// legacy
45-
Resource::TYPE_DOCUMENT,
46-
Resource::TYPE_ATTRIBUTE,
47-
Resource::TYPE_COLLECTION,
4843
];
4944

5045
public const GROUP_SETTINGS_RESOURCES = [];
@@ -142,7 +137,7 @@ public function getStatusCounters(): array
142137

143138
foreach ($this->cache->getAll() as $resourceType => $resources) {
144139
foreach ($resources as $resource) {
145-
if ($resourceType === Resource::TYPE_ROW && is_string($resource)) {
140+
if (($resourceType === Resource::TYPE_ROW || $resourceType === Resource::TYPE_DOCUMENT) && is_string($resource)) {
146141
$rowStatus = $resource;
147142
$status[$resourceType][$rowStatus]++;
148143

@@ -286,7 +281,7 @@ public function getReport(string $statusLevel = ''): array
286281

287282
foreach ($cache as $type => $resources) {
288283
foreach ($resources as $id => $resource) {
289-
if ($type === Resource::TYPE_ROW && is_string($resource)) {
284+
if (($type === Resource::TYPE_ROW || $type === Resource::TYPE_DOCUMENT) && is_string($resource)) {
290285
if ($statusLevel && $resource !== $statusLevel) {
291286
continue;
292287
}

0 commit comments

Comments
 (0)