diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index bdf44e2470..6fe6dff0ba 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1286,6 +1286,7 @@ return [ ] ], ], + 'deployments' => [ '$collection' => ID::custom(Database::METADATA), '$id' => ID::custom('deployments'), diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 9071e0cabe..026ce1eb2e 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -89,6 +89,7 @@ abstract class Migration '1.7.2' => 'V22', '1.7.3' => 'V22', '1.7.4' => 'V22', + '1.8.0' => 'V23', ]; /** diff --git a/src/Appwrite/Migration/Version/V23.php b/src/Appwrite/Migration/Version/V23.php new file mode 100644 index 0000000000..89ce938657 --- /dev/null +++ b/src/Appwrite/Migration/Version/V23.php @@ -0,0 +1,76 @@ + null, + fn () => [] + ); + } + + Console::info('Migrating collections'); + $this->migrateCollections(); + } + + /** + * Migrate Collections. + * + * @return void + * @throws Exception|Throwable + */ + private function migrateCollections(): void + { + $this->migrateMigrationsCollections(); + } + + /** + * Add `error` attribute on `migrations` collection. + */ + private function migrateMigrationsCollections(): void + { + $projectInternalId = $this->project->getSequence(); + + if ($projectInternalId !== 'projects') { + return; + } + + Console::info(" └── Migrating `migrations` collections."); + + if (empty($projectInternalId)) { + throw new Exception('Project ID is null'); + } + + /** + * direct access.\ + * same as `$this->collections['projects']['migrations']['$id']`. + */ + $migrationCollectionId = 'migrations'; + + try { + $attributes = ['error']; + $this->createAttributesFromCollection($this->dbForProject, $migrationCollectionId, $attributes); + } catch (\Throwable $th) { + Console::warning('Failed to create attributes "' . \implode(', ', $attributes) . "\" in collection {$migrationCollectionId}: {$th->getMessage()}"); + } + + $this->dbForProject->purgeCachedCollection($migrationCollectionId); + } +}