1
0
Fork 0
mirror of synced 2024-06-28 19:20:25 +12:00

Merge branch 'feat-db-refactor-ui-fixes' of https://github.com/appwrite/appwrite into feat-db-refactor-ui-fixes

This commit is contained in:
Torsten Dittmann 2021-10-27 15:45:12 +02:00
commit 8d326b1b7e

View file

@ -106,12 +106,18 @@ class DatabaseV1 extends Worker
$dbForExternal = $this->getExternalDB($projectId);
$collectionId = $collection->getId();
$key = $attribute->getAttribute('key', '');
$status = $attribute->getAttribute('status', '');
// possible states at this point:
// - available: should not land in queue; controller flips these to 'deleting'
// - processing: hasn't finished creating
// - deleting: was available, in deletion queue for first time
// - failed: attribute was never created
// - stuck: attribute was available but cannot be removed
try {
if(!$dbForExternal->deleteAttribute($collectionId, $key) && $attribute->getAttribute('status') !== 'failed') {
if($status !== 'failed' && !$dbForExternal->deleteAttribute($collectionId, $key)) {
throw new Exception('Failed to delete Attribute');
}
$dbForInternal->deleteDocument('attributes', $attribute->getId());
} catch (\Throwable $th) {
Console::error($th->getMessage());
@ -214,12 +220,12 @@ class DatabaseV1 extends Worker
$collectionId = $collection->getId();
$key = $index->getAttribute('key');
$status = $index->getAttribute('status', '');
try {
if(!$dbForExternal->deleteIndex($collectionId, $key) && $index->getAttribute('status') !== 'failed') {
if($status !== 'failed' && !$dbForExternal->deleteIndex($collectionId, $key)) {
throw new Exception('Failed to delete index');
}
$dbForInternal->deleteDocument('indexes', $index->getId());
} catch (\Throwable $th) {
Console::error($th->getMessage());