diff --git a/src/Database/Database.php b/src/Database/Database.php index 4b39ef231..d7193ef10 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -2527,8 +2527,8 @@ public function createDocument(string $collection, Document $document): Document $document ->setAttribute('$id', empty($document->getId()) ? ID::unique() : $document->getId()) ->setAttribute('$collection', $collection->getId()) - ->setAttribute('$createdAt', $time) - ->setAttribute('$updatedAt', $time); + ->setAttribute('$createdAt', empty($document->getCreatedAt()) ? $time : $document->getCreatedAt()) + ->setAttribute('$updatedAt', empty($document->getUpdatedAt()) ? $time : $document->getUpdatedAt()); $document = $this->encode($collection, $document);