diff --git a/app/cli.php b/app/cli.php index 09d8453b2a..3d761265ce 100644 --- a/app/cli.php +++ b/app/cli.php @@ -21,7 +21,6 @@ use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; use Utopia\Platform\Service; -use Utopia\Pools\Group; use Utopia\Registry\Registry; use Utopia\Span\Span; @@ -139,41 +138,6 @@ $container->set('getProjectDB', function (DatabaseFactory $databaseFactory, Data }; }, ['databaseFactory', 'dbForPlatform']); -$container->set('getLogsDB', function (Group $pools, Cache $cache, Authorization $authorization) { - $database = null; - - return function (?Document $project = null) use ($pools, $cache, &$database, $authorization) { - if ($database !== null && $project !== null && !$project->isEmpty() && $project->getId() !== 'console') { - $database->setTenant($project->getSequence()); - return $database; - } - - /** @var array $collections */ - $collections = Config::getParam('collections', []); - $logsCollections = $collections['logs'] ?? []; - $logsCollections = array_keys($logsCollections); - - $adapter = new DatabasePool($pools->get('logs')); - $database = new Database($adapter, $cache); - - $database - ->setDatabase(APP_DATABASE) - ->setAuthorization($authorization) - ->setSharedTables(true) - ->setNamespace('logsV1') - ->setGlobalCollections($logsCollections) - ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_TASK) - ->setMaxQueryValues(APP_DATABASE_QUERY_MAX_VALUES); - - // set tenant - if ($project !== null && !$project->isEmpty() && $project->getId() !== 'console') { - $database->setTenant($project->getSequence()); - } - - return $database; - }; -}, ['pools', 'cache', 'authorization']); - $container->set('usage', function () { return new UsageContext(); }, []); diff --git a/app/config/collections.php b/app/config/collections.php index 3af20ff2ac..3524a74b97 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -6,7 +6,6 @@ $projects = include __DIR__ . '/collections/projects.php'; $databases = include __DIR__ . '/collections/databases.php'; $vectorsdb = include __DIR__ . '/collections/vectorsdb.php'; $platform = include __DIR__ . '/collections/platform.php'; -$logs = include __DIR__ . '/collections/logs.php'; // see - http.php#245 // $collections['buckets']['files']; @@ -30,7 +29,6 @@ $collections = [ 'vectorsdb' => $vectorsdb, 'projects' => array_merge_recursive($projects, $common), 'console' => array_merge_recursive($platform, $common), - 'logs' => $logs, ]; return $collections; diff --git a/app/config/collections/logs.php b/app/config/collections/logs.php deleted file mode 100644 index 6d8a1828f2..0000000000 --- a/app/config/collections/logs.php +++ /dev/null @@ -1,5 +0,0 @@ -on(Constant::EVENT_START, function ($http) use ($payloadSize, $totalWorke /** @var array $collections */ $collections = Config::getParam('collections', []); - // create logs database first, `getLogsDB` is a callable. - createDatabase($container, 'getLogsDB', 'logs', $collections['logs'], $pools); - // create appwrite database, `dbForPlatform` is a direct access call. createDatabase($container, 'dbForPlatform', 'appwrite', $collections['console'], $pools, function (Database $dbForPlatform) use ($collections, $container) { $authorization = $container->get('authorization'); diff --git a/app/init/registers.php b/app/init/registers.php index a91e0df583..d24c30b11f 100644 --- a/app/init/registers.php +++ b/app/init/registers.php @@ -98,12 +98,6 @@ $register->set('pools', function () { 'multiple' => true, 'schemes' => ['postgresql'], ], - 'logs' => [ - 'type' => 'database', - 'dsns' => System::getEnv('_APP_CONNECTIONS_DB_LOGS', $fallbackForDB), - 'multiple' => false, - 'schemes' => ['mongodb','mariadb', 'mysql','postgresql'], - ], 'publisher' => [ 'type' => 'publisher', 'dsns' => $fallbackForRedis, diff --git a/app/init/resources.php b/app/init/resources.php index e4ff8048e8..5d73baad9a 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -268,25 +268,6 @@ $container->set('dbForPlatform', fn (DatabaseFactory $databaseFactory) => $datab ['host' => \gethostname(), 'project' => 'console'] ), ['databaseFactory']); -$container->set('getLogsDB', function (DatabaseFactory $databaseFactory) { - $database = null; - - return function (?Document $project = null) use ($databaseFactory, &$database) { - if ($database !== null && $project !== null && !$project->isEmpty() && $project->getId() !== 'console') { - $database->setTenant($project->getSequence()); - return $database; - } - - $database = $databaseFactory->logs( - $project, - APP_DATABASE_TIMEOUT_MILLISECONDS_API, - APP_DATABASE_QUERY_MAX_VALUES - ); - - return $database; - }; -}, ['databaseFactory']); - $container->set('cache', function (Group $pools, Telemetry $telemetry) { $list = Config::getParam('pools-cache', []); $adapters = []; diff --git a/app/init/resources/request.php b/app/init/resources/request.php index fc9337cf5b..00d5dfabe4 100644 --- a/app/init/resources/request.php +++ b/app/init/resources/request.php @@ -244,17 +244,6 @@ return function (Container $context): void { }; }, ['databaseFactory', 'dbForPlatform']); - $context->set('getLogsDB', function (DatabaseFactory $databaseFactory) { - - return function (?Document $project = null) use ($databaseFactory) { - return $databaseFactory->logs( - $project, - APP_DATABASE_TIMEOUT_MILLISECONDS_API, - APP_DATABASE_QUERY_MAX_VALUES - ); - }; - }, ['databaseFactory']); - /** * List of allowed request hostnames for the request. */ diff --git a/app/init/worker/message.php b/app/init/worker/message.php index c5913a11f5..4c1182fa65 100644 --- a/app/init/worker/message.php +++ b/app/init/worker/message.php @@ -109,26 +109,6 @@ return function (Container $container): void { }; }, ['databaseFactory', 'project']); - $container->set('getLogsDB', function (DatabaseFactory $databaseFactory) { - $database = null; - - return function (?Document $project = null) use ($databaseFactory, &$database) { - if ($database !== null && $project !== null && !$project->isEmpty() && $project->getId() !== 'console') { - $database->setTenant($project->getSequence()); - - return $database; - } - - $database = $databaseFactory->logs( - $project, - APP_DATABASE_TIMEOUT_MILLISECONDS_WORKER, - APP_DATABASE_QUERY_MAX_VALUES_WORKER - ); - - return $database; - }; - }, ['databaseFactory']); - $container->set('abuseRetention', function () { return \time() - (int) System::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', 86400); // 1 day }, []); diff --git a/src/Appwrite/Database/Factory.php b/src/Appwrite/Database/Factory.php index b01dd8b343..7bcdba1d35 100644 --- a/src/Appwrite/Database/Factory.php +++ b/src/Appwrite/Database/Factory.php @@ -67,35 +67,6 @@ class Factory return $this->configureProject($database, $project, $dsn); } - public function logs( - ?Document $project = null, - int $timeout = 0, - int $maxQueryValues = 0, - array $metadata = [], - ): Database { - /** @var array $collections */ - $collections = Config::getParam('collections', []); - $logsCollections = \array_keys($collections['logs'] ?? []); - - $database = $this->newDatabase($this->adapter('logs')); - - $database - ->setDatabase($this->database) - ->setAuthorization($this->authorization) - ->setDropUnknownAttributes(true) - ->setSharedTables(true) - ->setGlobalCollections($logsCollections) - ->setNamespace('logsV1'); - - if ($project !== null && !$project->isEmpty() && $project->getId() !== 'console') { - $database->setTenant($project->getSequence()); - } - - $this->configureOptions($database, $timeout, $maxQueryValues, $metadata); - - return $database; - } - /** * Databases and tables the caller owns. Unknown attributes stay a rejected write here: * the schema is theirs, so dropping one would silently discard data they sent. diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index a68beff1ee..d64db422a9 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -63,7 +63,6 @@ class Deletes extends Action ->inject('dbForPlatform') ->inject('getProjectDB') ->inject('getDatabasesDB') - ->inject('getLogsDB') ->inject('deviceForFiles') ->inject('deviceForFunctions') ->inject('deviceForSites') @@ -94,7 +93,6 @@ class Deletes extends Action Database $dbForPlatform, callable $getProjectDB, callable $getDatabasesDB, - callable $getLogsDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForSites, @@ -128,7 +126,6 @@ class Deletes extends Action $dbForPlatform, $getProjectDB, $getDatabasesDB, - $getLogsDB, $deviceForFiles, $deviceForFunctions, $deviceForSites, @@ -222,7 +219,6 @@ class Deletes extends Action Database $dbForPlatform, callable $getProjectDB, callable $getDatabasesDB, - callable $getLogsDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForSites, diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php index dffb1f6b48..688a67a20d 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -30,8 +30,7 @@ class Base extends Queries $config['projects'], $config['buckets'], $config['databases'], - $config['console'], - $config['logs'] + $config['console'] ); $collection = $collections[$collection];