Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 src/Migration/Resources/Database/Columns/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(
$key,
$table,
options: [
'relatedTable' => $relatedTable,
'relatedCollection' => $relatedTable,
'relationType' => $relationType,
'twoWay' => $twoWay,
'twoWayKey' => $twoWayKey,
Expand Down
8 changes: 4 additions & 4 deletions src/Migration/Sources/Appwrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -998,13 +998,13 @@ private function exportIndexes(int $batchSize): void

foreach ($response as $index) {
$indexes[] = new Index(
'unique()',
$index['$id'],
Comment thread
abnegate marked this conversation as resolved.
$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'],
);
Expand Down
13 changes: 6 additions & 7 deletions src/Migration/Sources/Appwrite/Reader/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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(
Expand Down
9 changes: 2 additions & 7 deletions src/Migration/Transfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Comment on lines -43 to -47
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having these here just duplicates what were store in the migrations resources, we now the have fallbacks to handle existing migrations that reference these

];

public const GROUP_SETTINGS_RESOURCES = [];
Expand Down Expand Up @@ -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]++;

Expand Down Expand Up @@ -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;
}
Expand Down