From e15a9ac2800618d4b91a6c0f2a18c6cd5d81a45e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 22 Aug 2023 19:36:46 -0400 Subject: [PATCH] Clean up attributes to be deleted --- src/Appwrite/Migration/Version/V19.php | 51 ++++++++++++++++++-------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php index 8e727ddd9f..921aacbded 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -39,21 +39,8 @@ class V19 extends Migration Console::info('Migrating Documents'); $this->forEachDocument([$this, 'fixDocument']); - try { - $this->projectDB->deleteAttribute('projects', 'domains'); - $this->projectDB->deleteCachedCollection('projects'); - } catch (\Throwable $th) { - Console::warning("'domains' from projects: {$th->getMessage()}"); - } - - try { - $this->projectDB->deleteAttribute('functions', 'schedule'); - $this->projectDB->deleteCachedCollection('functions'); - } catch (\Throwable $th) { - Console::warning("'schedule' from functions: {$th->getMessage()}"); - } - - // TODO: delete builds stderr and stdout + Console::log('Cleaning Up Collections'); + $this->cleanCollections(); } /** @@ -124,6 +111,7 @@ class V19 extends Migration } catch (\Throwable $th) { Console::warning("'collectionInternalId' from {$id}: {$th->getMessage()}"); } + try { $this->createAttributeFromCollection($this->projectDB, $id, 'error'); } catch (\Throwable $th) { @@ -654,4 +642,37 @@ class V19 extends Migration return $document; } + + private function cleanCollections(): void + { + try { + $this->projectDB->deleteAttribute('projects', 'domains'); + } catch (\Throwable $th) { + Console::warning("'domains' from projects: {$th->getMessage()}"); + } + + $this->projectDB->deleteCachedCollection('projects'); + + try { + $this->projectDB->deleteAttribute('functions', 'schedule'); + } catch (\Throwable $th) { + Console::warning("'schedule' from functions: {$th->getMessage()}"); + } + + $this->projectDB->deleteCachedCollection('functions'); + + try { + $this->projectDB->deleteAttribute('builds', 'stderr'); + } catch (\Throwable $th) { + Console::warning("'stderr' from builds: {$th->getMessage()}"); + } + + try { + $this->projectDB->deleteAttribute('builds', 'stdout'); + } catch (\Throwable $th) { + Console::warning("'stdout' from builds: {$th->getMessage()}"); + } + + $this->projectDB->deleteCachedCollection('builds'); + } }