diff --git a/app/config/collections.php b/app/config/collections.php index d23f452b08..a4ccc6eeb4 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -2627,6 +2627,17 @@ $collections = [ 'array' => false, 'filters' => [], ], + [ + '$id' => ID::custom('outputSize'), + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => ID::custom('stderr'), 'type' => Database::VAR_STRING, diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index d98746520a..a0c237fd5f 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -48,6 +48,7 @@ abstract class Migration '1.1.0' => 'V16', '1.1.1' => 'V16', '1.1.2' => 'V16', + '1.2.0' => 'V17', ]; /** diff --git a/src/Appwrite/Migration/Version/V17.php b/src/Appwrite/Migration/Version/V17.php new file mode 100644 index 0000000000..c7e73fa1b5 --- /dev/null +++ b/src/Appwrite/Migration/Version/V17.php @@ -0,0 +1,76 @@ + null, + fn () => [] + ); + } + + Console::log('Migrating Project: ' . $this->project->getAttribute('name') . ' (' . $this->project->getId() . ')'); + + Console::info('Migrating Collections'); + $this->migrateCollections(); + + // Console::info('Migrating Documents'); + // $this->forEachDocument([$this, 'fixDocument']); + } + + /** + * Migrate all Collections. + * + * @return void + */ + protected function migrateCollections(): void + { + foreach ($this->collections as $collection) { + $id = $collection['$id']; + + Console::log("Migrating Collection \"{$id}\""); + + $this->projectDB->setNamespace("_{$this->project->getInternalId()}"); + + switch ($id) { + case 'builds': + try { + /** + * Create 'region' attribute + */ + $this->createAttributeFromCollection($this->projectDB, $id, 'outputSize'); + } catch (\Throwable $th) { + Console::warning("'region' from {$id}: {$th->getMessage()}"); + } + default: + break; + } + + usleep(50000); + } + } + + /** + * Fix run on each document + * + * @param \Utopia\Database\Document $document + * @return \Utopia\Database\Document + */ + protected function fixDocument(Document $document) + { + return $document; + } +} \ No newline at end of file