diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index e80e2888b2..7d8ddd8a79 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -234,7 +234,21 @@ App::post('/v1/projects') $attributes = \array_map(fn ($attribute) => new Document($attribute), $collection['attributes']); $indexes = \array_map(fn (array $index) => new Document($index), $collection['indexes']); - $dbForProject->createCollection($key, $attributes, $indexes); + + try { + $dbForProject->createCollection($key, $attributes, $indexes); + } catch (Duplicate) { + if (!$globalCollections) { + $dbForProject->createDocument(Database::METADATA, new Document([ + '$id' => ID::custom($key), + '$permissions' => [Permission::create(Role::any())], + 'name' => $key, + 'attributes' => $attributes, + 'indexes' => $indexes, + 'documentSecurity' => true + ])); + } + } } } diff --git a/composer.lock b/composer.lock index fdce5e2809..e0c0b534b4 100644 --- a/composer.lock +++ b/composer.lock @@ -7038,5 +7038,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" }