diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 22ee9e3c03..0f3d54f8ce 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -131,7 +131,7 @@ App::post('/v1/projects') 'database' => $pdo->getName() ])); - $dbForProject = DatabasePool::getDatabase($pdo->getConnection(), $cache, "_{$project->getInternalId()}"); + $dbForProject = Pools::getDatabase($pdo->getConnection(), $cache, "_{$project->getInternalId()}"); $dbForProject->create(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); $audit = new Audit($dbForProject); diff --git a/app/init.php b/app/init.php index 9feae34e63..0f6b7a7542 100644 --- a/app/init.php +++ b/app/init.php @@ -908,14 +908,14 @@ App::setResource('dbForProject', function ($dbPool, $cache, Document $project) { $database = $dbPool->getConsoleDB(); } $pdo = $dbPool->getPDOFromPool($database); - $database = DatabasePool::getDatabase($pdo->getConnection(), $cache, "_{$project->getInternalId()}"); + $database = Pools::getDatabase($pdo->getConnection(), $cache, "_{$project->getInternalId()}"); return $database; }, ['dbPool', 'cache', 'project']); App::setResource('dbForConsole', function ($dbPool, $cache) { $database = $dbPool->getConsoleDB(); $pdo = $dbPool->getPDOFromPool($database); - $database = DatabasePool::getDatabase($pdo->getConnection(), $cache, '_console'); + $database = Pools::getDatabase($pdo->getConnection(), $cache, '_console'); return $database; }, ['dbPool', 'cache']); diff --git a/app/realtime.php b/app/realtime.php index ab39a18a57..9df6ed5e4f 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -1,7 +1,7 @@ getConsoleDB(); $pdo = $dbPool->getPDOFromPool($database); - $database = DatabasePool::wait( - DatabasePool::getDatabase($pdo->getConnection(), $redis, '_console'), + $database = Pools::wait( + Pools::getDatabase($pdo->getConnection(), $redis, '_console'), 'realtime' ); @@ -109,8 +109,8 @@ function getDatabase(Registry &$register, string $projectId) $project = Authorization::skip(fn() => $database->getDocument('projects', $projectId)); $database = $project->getAttribute('database', ''); $pdo = $dbPool->getPDOFromPool($database); - $database = DatabasePool::wait( - DatabasePool::getDatabase($pdo->getConnection(), $redis, "_{$project->getInternalId()}"), + $database = Pools::wait( + Pools::getDatabase($pdo->getConnection(), $redis, "_{$project->getInternalId()}"), 'realtime' ); } @@ -479,13 +479,13 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re /** Get the console DB */ $database = $dbPool->getConsoleDB(); $pdo = $dbPool->getPDOFromPool($database); - $database = DatabasePool::getDatabase($pdo->getConnection(), $redis, '_console'); + $database = Pools::getDatabase($pdo->getConnection(), $redis, '_console'); if ($projectId !== 'console') { $project = Authorization::skip(fn() => $database->getDocument('projects', $projectId)); $database = $project->getAttribute('database', ''); $pdo = $dbPool->getPDOFromPool($database); - $database = DatabasePool::getDatabase($pdo->getConnection(), $redis, "_{$project->getInternalId()}"); + $database = Pools::getDatabase($pdo->getConnection(), $redis, "_{$project->getInternalId()}"); } /* diff --git a/app/tasks/doctor.php b/app/tasks/doctor.php index 634381ba41..6875b65092 100644 --- a/app/tasks/doctor.php +++ b/app/tasks/doctor.php @@ -96,7 +96,7 @@ $cli } try { - $dbPool = $register->get('dbPool'); /* @var $dbPool DatabasePool */ + $dbPool = $register->get('dbPool'); /* @var $dbPool Pools */ $database = $dbPool->getConsoleDB(); $pdo = $dbPool->getPDO($database); Console::success('Database............connected 👍'); diff --git a/app/tasks/maintenance.php b/app/tasks/maintenance.php index af4719d119..8d684d8bed 100644 --- a/app/tasks/maintenance.php +++ b/app/tasks/maintenance.php @@ -3,7 +3,7 @@ global $cli; use Appwrite\Auth\Auth; -use Appwrite\Database\DatabasePool; +use Appwrite\Database\Pools; use Appwrite\Event\Certificate; use Appwrite\Event\Delete; use Utopia\App; @@ -121,8 +121,8 @@ $cli $database = $dbPool->getConsoleDB(); $pdo = $dbPool->getPDO($database); - $database = DatabasePool::wait( - DatabasePool::getDatabase($pdo, $redis, '_console'), + $database = Pools::wait( + Pools::getDatabase($pdo, $redis, '_console'), 'certificates', ); diff --git a/app/tasks/usage.php b/app/tasks/usage.php index 214fd27b5d..d9215833c7 100644 --- a/app/tasks/usage.php +++ b/app/tasks/usage.php @@ -2,7 +2,7 @@ global $cli, $register; -use Appwrite\Database\DatabasePool; +use Appwrite\Database\Pools; use Appwrite\Usage\Calculators\Aggregator; use Appwrite\Usage\Calculators\Database; use Appwrite\Usage\Calculators\TimeSeries; @@ -131,8 +131,8 @@ $cli $database = $dbPool->getConsoleDB(); $pdo = $dbPool->getPDO($database); - $database = DatabasePool::wait( - DatabasePool::getDatabase($pdo, $redis, '_console'), + $database = Pools::wait( + Pools::getDatabase($pdo, $redis, '_console'), 'projects', ); diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php index c1ef264670..e394f416f3 100644 --- a/src/Appwrite/Resque/Worker.php +++ b/src/Appwrite/Resque/Worker.php @@ -2,7 +2,8 @@ namespace Appwrite\Resque; -use Appwrite\Database\DatabasePool; +use Exception; +use Appwrite\Database\Pools; use Utopia\App; use Utopia\Database\Database; use Utopia\Storage\Device; @@ -13,7 +14,6 @@ use Utopia\Storage\Device\Linode; use Utopia\Storage\Device\Wasabi; use Utopia\Storage\Device\Backblaze; use Utopia\Storage\Device\S3; -use Exception; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; @@ -175,8 +175,8 @@ abstract class Worker $dbPool = $register->get('dbPool'); $namespace = "_$internalId"; $pdo = $dbPool->getPDO($database); - $dbForProject = DatabasePool::wait( - DatabasePool::getDatabase($pdo, $cache, $namespace), + $dbForProject = Pools::wait( + Pools::getDatabase($pdo, $cache, $namespace), 'projects' ); @@ -199,8 +199,8 @@ abstract class Worker $namespace = "_console"; $pdo = $dbPool->getPDO($database); - $dbForConsole = DatabasePool::wait( - DatabasePool::getDatabase($pdo, $cache, $namespace), + $dbForConsole = Pools::wait( + Pools::getDatabase($pdo, $cache, $namespace), '_metadata' );