diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index bf0cee3527..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' => 65535, + '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 7a6d58d59f..a4027b506e 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; use Utopia\Database\Exception\Conflict; @@ -132,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; } @@ -201,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'); + } }