From f68d49c4d63fce8a663b5f0c7d6b3852dae3feef Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 29 Aug 2025 18:19:29 +0530 Subject: [PATCH 1/3] updated the migration error size attribute --- app/config/collections/projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index 7fc82b7441..4fd44c7725 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -2345,7 +2345,7 @@ return [ '$id' => ID::custom('errors'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 65535, + 'size' => 131070, 'signed' => true, 'required' => true, 'default' => null, From ac604b11e3b241e504d14f14b2e09750e855c705 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Mon, 1 Sep 2025 13:13:52 +0530 Subject: [PATCH 2/3] added migration script --- src/Appwrite/Migration/Version/V23.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Appwrite/Migration/Version/V23.php b/src/Appwrite/Migration/Version/V23.php index d5caf2ab3c..c26c45d732 100644 --- a/src/Appwrite/Migration/Version/V23.php +++ b/src/Appwrite/Migration/Version/V23.php @@ -6,6 +6,7 @@ use Appwrite\Migration\Migration; use Exception; use Throwable; use Utopia\CLI\Console; +use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; @@ -29,6 +30,9 @@ class V23 extends Migration Console::info('Migrating databases'); $this->migrateDatabases(); + + Console::info('Migrating migration collection'); + $this->updateMigrateErrorSize(); } /** @@ -49,4 +53,26 @@ class V23 extends Migration $this->dbForProject->updateDocuments('databases', new Document(['type' => 'legacy'])); } + /** + * Update migration collection error attribute + * + * @return void + * @throws Exception|Throwable + */ + + private function updateMigrateErrorSize(): void + { + if ($this->project->getId() === 'console') { + return; + } + + $collection = Config::getParam('collections', [])['projects'] ?? []; + $migrationAttributes = $collection['migrations']['attributes']; + $attributeKey = \array_search('errors', \array_column($migrationAttributes, '$id')); + $migrationAttributes[$attributeKey]['size'] = 131070; + $migration = $this->dbForProject->getCollection('migrations'); + $migration->setAttribute('attributes', $migrationAttributes); + $this->dbForProject->updateDocument($migration->getCollection(), $migration->getId(), $migration); + $this->dbForProject->purgeCachedCollection('migrations'); + } } From 7c408d675ea258f202eac6d9090447f912afde64 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Fri, 7 Nov 2025 14:30:22 +0530 Subject: [PATCH 3/3] pr followups --- app/config/collections/projects.php | 2 +- src/Appwrite/Migration/Version/V23.php | 49 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index c7205c667d..dae0337dc9 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -2345,7 +2345,7 @@ return [ '$id' => ID::custom('errors'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 131070, + 'size' => 1_000_000, 'signed' => true, 'required' => true, 'default' => null, diff --git a/src/Appwrite/Migration/Version/V23.php b/src/Appwrite/Migration/Version/V23.php index f9fd63346f..a4027b506e 100644 --- a/src/Appwrite/Migration/Version/V23.php +++ b/src/Appwrite/Migration/Version/V23.php @@ -133,6 +133,13 @@ class V23 extends Migration } $this->dbForProject->purgeCachedCollection($id); break; + case 'migrations': + try { + $this->updateMigrateErrorSize(); + } catch (\Throwable $th) { + Console::warning("Failed to migration error attribute size in collection {$id}: {$th->getMessage()}"); + } + default: break; } @@ -202,4 +209,46 @@ class V23 extends Migration } return $document; } + + /** + * Update migration attribute size + * @return void + */ + private function updateMigrateErrorSize(): void + { + + if ($this->project->getId() === 'console') { + return; + } + + // Read-modify-write from the live schema to avoid overwriting unrelated changes. + $migration = $this->dbForProject->getCollection('migrations'); + $attributes = $migration->getAttribute('attributes', []); + $attrsArray = \array_map(fn (Document $doc) => $doc->getArrayCopy(), $attributes); + $errorsIdx = \array_search('errors', \array_column($attrsArray, '$id')); + + if ($errorsIdx === false) { + Console::warning("Skipping: 'errors' attribute not found in migrations collection for project {$this->project->getId()}"); + return; + } + + $desiredSize = 1_000_000; + $migrationAttributes = Config::getParam('collections', [])['projects']['migrations']['attributes'] ?? []; + $migrationIndex = \array_search('errors', \array_column($migrationAttributes, '$id')); + + if ($migrationIndex !== false && isset($migrationAttributes[$migrationIndex]['size'])) { + $desiredSize = (int) $migrationAttributes[$migrationIndex]['size']; + } + + $currentSize = (int) ($attributes[$errorsIdx]['size'] ?? 0); + + if ($currentSize === $desiredSize) { + Console::warning("Skipping: 'errors' attribute already of desired size {$desiredSize} in migrations collection for project {$this->project->getId()}"); + return; + } + $attributes[$errorsIdx]['size'] = $desiredSize; + $migration->setAttribute('attributes', $attributes); + $this->dbForProject->updateDocument($migration->getCollection(), $migration->getId(), $migration); + $this->dbForProject->purgeCachedCollection('migrations'); + } }