diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index e0b83dcab1..304c98f208 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -35,6 +35,7 @@ use Utopia\Database\Validator\UID; use Utopia\Domains\Validator\PublicDomain; use Utopia\DSN\DSN; use Utopia\Locale\Locale; +use Utopia\Pools\Connection; use Utopia\Pools\Group; use Utopia\System\System; use Utopia\Validator\ArrayList; @@ -84,10 +85,11 @@ App::post('/v1/projects') ->inject('request') ->inject('response') ->inject('dbForPlatform') + ->inject('connectionForProject') ->inject('cache') ->inject('pools') ->inject('hooks') - ->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Request $request, Response $response, Database $dbForPlatform, Cache $cache, Group $pools, Hooks $hooks) { + ->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Request $request, Response $response, Database $dbForPlatform, Connection $connectionForProject, Cache $cache, Group $pools, Hooks $hooks) { $team = $dbForPlatform->getDocument('teams', $teamId); @@ -195,8 +197,7 @@ App::post('/v1/projects') $dsn = new DSN('mysql://' . $dsn); } - $adapter = $pools->get($dsn->getHost())->pop()->getResource(); - $dbForProject = new Database($adapter, $cache); + $dbForProject = new Database($connectionForProject->getResource(), $cache); $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', ''));