Skip to content

Commit 8108e0b

Browse files
updated to TablesDB
1 parent 9726690 commit 8108e0b

2 files changed

Lines changed: 14 additions & 23 deletions

File tree

src/Migration/Sources/Appwrite.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
use Appwrite\AppwriteException;
66
use Appwrite\Client;
77
use Appwrite\Query;
8-
use Appwrite\Services\Databases;
98
use Appwrite\Services\Functions;
109
use Appwrite\Services\Messaging;
1110
use Appwrite\Services\Sites;
1211
use Appwrite\Services\Storage;
12+
use Appwrite\Services\TablesDB;
1313
use Appwrite\Services\Teams;
1414
use Appwrite\Services\Users;
1515
use Utopia\Database\Database as UtopiaDatabase;
@@ -127,7 +127,7 @@ public function __construct(
127127

128128
switch ($this->source) {
129129
case static::SOURCE_API:
130-
$this->reader = new APIReader(new Databases($this->client));
130+
$this->reader = new APIReader(new TablesDB($this->client));
131131
break;
132132

133133
case static::SOURCE_DATABASE:

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

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
use Appwrite\AppwriteException;
66
use Appwrite\Query;
7-
use Appwrite\Services\Databases;
8-
/* use Appwrite\Services\Tables; */
7+
use Appwrite\Services\TablesDB;
98
use Utopia\Migration\Resource;
109
use Utopia\Migration\Resources\Database\Database;
1110
use Utopia\Migration\Resources\Database\Table;
@@ -17,8 +16,7 @@
1716
class API implements Reader
1817
{
1918
public function __construct(
20-
private readonly Databases $database,
21-
/* private readonly Tables $table, */
19+
private readonly TablesDB $database,
2220
) {
2321
}
2422

@@ -73,13 +71,12 @@ public function report(array $resources, array &$report, array $resourceIds = []
7371
$lastTable = null;
7472

7573
while (true) {
76-
/* $currentTables = $this->tables->list(...); */
77-
$currentTables = $this->database->listCollections(
74+
$currentTables = $this->database->listTables(
7875
$databaseId,
7976
$lastTable
8077
? [Query::cursorAfter($lastTable)]
8178
: [Query::limit($pageLimit)]
82-
)['collections']; /* ['tables'] */
79+
)['tables'];
8380

8481
$tables = \array_merge($tables, $currentTables);
8582
$lastTable = $tables[count($tables) - 1]['$id'] ?? null;
@@ -108,8 +105,7 @@ public function report(array $resources, array &$report, array $resourceIds = []
108105
}
109106

110107
if (Resource::isSupported(Resource::TYPE_ROW, $resources)) {
111-
/* $rowsResponse = $this->tables->listRows(...) */
112-
$rowsResponse = $this->database->listDocuments(
108+
$rowsResponse = $this->database->listRows(
113109
$databaseId,
114110
$tableId,
115111
[Query::limit(1)]
@@ -137,11 +133,10 @@ public function listDatabases(array $queries = []): array
137133
*/
138134
public function listTables(Database $resource, array $queries = []): array
139135
{
140-
/* $this->tables->list(...)['tables'] */
141-
return $this->database->listCollections(
136+
return $this->database->listTables(
142137
$resource->getId(),
143138
$queries
144-
)['collections'];
139+
)['tables'];
145140
}
146141

147142
/**
@@ -152,12 +147,11 @@ public function listTables(Database $resource, array $queries = []): array
152147
*/
153148
public function listColumns(Table $resource, array $queries = []): array
154149
{
155-
/* $this->tables->listColumns(...)['columns'] */
156-
return $this->database->listAttributes(
150+
return $this->database->listColumns(
157151
$resource->getDatabase()->getId(),
158152
$resource->getId(),
159153
$queries
160-
)['attributes'];
154+
)['columns'];
161155
}
162156

163157
/**
@@ -168,7 +162,6 @@ public function listColumns(Table $resource, array $queries = []): array
168162
*/
169163
public function listIndexes(Table $resource, array $queries = []): array
170164
{
171-
/* $this->tables->listIndexes(...)['indexes'] */
172165
return $this->database->listIndexes(
173166
$resource->getDatabase()->getId(),
174167
$resource->getId(),
@@ -185,12 +178,11 @@ public function listIndexes(Table $resource, array $queries = []): array
185178
*/
186179
public function listRows(Table $resource, array $queries = []): array
187180
{
188-
/* $this->tables->listRows(...)['rows'] */
189-
return $this->database->listDocuments(
181+
return $this->database->listRows(
190182
$resource->getDatabase()->getId(),
191183
$resource->getId(),
192184
$queries
193-
)['documents'];
185+
)['rows'];
194186
}
195187

196188
/**
@@ -202,8 +194,7 @@ public function listRows(Table $resource, array $queries = []): array
202194
*/
203195
public function getRow(Table $resource, string $rowId, array $queries = []): array
204196
{
205-
/* $this->tables->getRow(...) */
206-
return $this->database->getDocument(
197+
return $this->database->getRow(
207198
$resource->getDatabase()->getId(),
208199
$resource->getId(),
209200
$rowId,

0 commit comments

Comments
 (0)