Skip to content

Commit

Permalink
Delete table if metadata create failed
Browse files Browse the repository at this point in the history
  • Loading branch information
abnegate committed Nov 25, 2024
1 parent 0e58017 commit 43180e3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,12 @@ public function createCollection(string $id, array $attributes = [], array $inde
return new Document(self::COLLECTION);
}

$createdCollection = $this->silent(fn () => $this->createDocument(self::METADATA, $collection));
try {
$createdCollection = $this->silent(fn () => $this->createDocument(self::METADATA, $collection));
} catch (Exception $e) {
$this->adapter->deleteCollection($id);
throw $e;
}

$this->trigger(self::EVENT_COLLECTION_CREATE, $createdCollection);

Expand Down

0 comments on commit 43180e3

Please sign in to comment.