Skip to content

Commit 8a17cd5

Browse files
authored
Merge pull request #571 from utopia-php/fix-collection-delete-v1
Fix: collection deletion on V1
2 parents e868ce8 + 92d12d4 commit 8a17cd5

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/Database/Adapter/MariaDB.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,13 @@ public function deleteCollection(string $id): bool
331331

332332
$sql = $this->trigger(Database::EVENT_COLLECTION_DELETE, $sql);
333333

334-
return $this->getPDO()
335-
->prepare($sql)
336-
->execute();
334+
try {
335+
return $this->getPDO()
336+
->prepare($sql)
337+
->execute();
338+
} catch (PDOException $e) {
339+
throw $this->processException($e);
340+
}
337341
}
338342

339343
/**

src/Database/Database.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,14 @@ public function deleteCollection(string $id): bool
14491449
$this->deleteRelationship($collection->getId(), $relationship->getId());
14501450
}
14511451

1452-
$this->adapter->deleteCollection($id);
1452+
try {
1453+
$this->adapter->deleteCollection($id);
1454+
} catch (NotFoundException $e) {
1455+
// HACK: Metadata should still be updated, can be removed when null tenant collections are supported.
1456+
if (!$this->adapter->getSharedTables() || !$this->isMigrating()) {
1457+
throw $e;
1458+
}
1459+
}
14531460

14541461
if ($id === self::METADATA) {
14551462
$deleted = true;

0 commit comments

Comments
 (0)