From d806bdbca7d35c30a184243c01ba26202a7a70a9 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 8 Oct 2025 11:17:12 +0530 Subject: [PATCH] added project region in the get database dsn --- .../Platform/Modules/Databases/Http/Databases/Create.php | 5 +++-- .../Platform/Modules/Databases/Http/DocumentsDB/Create.php | 1 + .../Platform/Modules/Databases/Http/TablesDB/Create.php | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php index dc3e080e48..8de2ba9003 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php @@ -124,13 +124,14 @@ class Create extends Action ->param('databaseId', '', new CustomId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('name', '', new Text(128), 'Database name. Max length: 128 chars.') ->param('enabled', true, new Boolean(), 'Is the database enabled? When set to \'disabled\', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.', true) + ->inject('project') ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') ->callback($this->action(...)); } - public function action(string $databaseId, string $name, bool $enabled, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $name, bool $enabled, Document $project, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void { $databaseId = $databaseId == 'unique()' ? ID::unique() : $databaseId; @@ -141,7 +142,7 @@ class Create extends Action 'enabled' => $enabled, 'search' => implode(' ', [$databaseId, $name]), 'type' => $this->getDatabaseType(), - 'database' => $this->getDatabaseDSN() + 'database' => $this->getDatabaseDSN($project->getAttribute('region')) ])); } catch (DuplicateException) { throw new Exception(Exception::DATABASE_ALREADY_EXISTS); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Create.php index 108113e0c1..a59daf9482 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Create.php @@ -49,6 +49,7 @@ class Create extends DatabaseCreate ->param('databaseId', '', new CustomId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('name', '', new Text(128), 'Database name. Max length: 128 chars.') ->param('enabled', true, new Boolean(), 'Is the database enabled? When set to \'disabled\', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.', true) + ->inject('project') ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Create.php index 8993f00368..2cc92c7b67 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Create.php @@ -49,6 +49,7 @@ class Create extends DatabaseCreate ->param('databaseId', '', new CustomId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('name', '', new Text(128), 'Database name. Max length: 128 chars.') ->param('enabled', true, new Boolean(), 'Is the database enabled? When set to \'disabled\', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.', true) + ->inject('project') ->inject('response') ->inject('dbForProject') ->inject('queueForEvents')