Skip to content

Commit

Permalink
Merge pull request #44 from utopia-php/original-uid
Browse files Browse the repository at this point in the history
OriginalId database resource
  • Loading branch information
abnegate authored Oct 7, 2024
2 parents e43ef28 + 14703f5 commit 37bf417
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Migration/Destinations/Appwrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ protected function createDatabase(Database $resource): bool
'search' => implode(' ', [$resource->getId(), $resource->getDatabaseName()]),
'$createdAt' => $resource->getCreatedAt(),
'$updatedAt' => $resource->getUpdatedAt(),
'originalId' => empty($resource->getOriginalId()) ? null : $resource->getOriginalId(),
]));

$resource->setInternalId($database->getInternalId());
Expand Down Expand Up @@ -901,11 +902,12 @@ protected function createDocument(Document $resource, bool $isLast): bool
$databaseInternalId = $database->getInternalId();
$collectionInternalId = $collection->getInternalId();

$this->database
$this->database->skipRelationships(fn () => $this->database
->createDocuments(
'database_' . $databaseInternalId . '_collection_' . $collectionInternalId,
$this->documentBuffer
);
));

} finally {
$this->documentBuffer = [];
}
Expand Down
4 changes: 4 additions & 0 deletions src/Migration/Resources/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __construct(
protected string $createdAt = '',
protected string $updatedAt = '',
protected bool $enabled = true,
protected string $originalId = '',
) {
$this->id = $id;
}
Expand All @@ -31,6 +32,8 @@ public function __construct(
* name: string,
* createdAt: string,
* updatedAt: string,
* enabled: bool,
* originalId: string|null,
* } $array
*/
public static function fromArray(array $array): self
Expand All @@ -41,6 +44,7 @@ public static function fromArray(array $array): self
createdAt: $array['createdAt'] ?? '',
updatedAt: $array['updatedAt'] ?? '',
enabled: $array['enabled'] ?? true,
originalId: $array['originalId'] ?? '',
);
}

Expand Down

0 comments on commit 37bf417

Please sign in to comment.