diff --git a/composer.json b/composer.json index 3920351c06..5b13227d2b 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.12.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.64.*", + "utopia-php/database": "0.65.*", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index cc2ad97b6c..c6c9ae2900 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6a54c8bc4f9f14cd3883f55880864630", + "content-hash": "51ff891ef6cee8a3f8c4e5187b7fd479", "packages": [ { "name": "adhocore/jwt", @@ -3497,16 +3497,16 @@ }, { "name": "utopia-php/database", - "version": "0.64.2", + "version": "0.65.0", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "dc9c4a68c93e8bea2dfaa76d1ba308be539998bd" + "reference": "e589efdc5da1216523a758e8af358866d4fb563f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/dc9c4a68c93e8bea2dfaa76d1ba308be539998bd", - "reference": "dc9c4a68c93e8bea2dfaa76d1ba308be539998bd", + "url": "https://api.github.com/repos/utopia-php/database/zipball/e589efdc5da1216523a758e8af358866d4fb563f", + "reference": "e589efdc5da1216523a758e8af358866d4fb563f", "shasum": "" }, "require": { @@ -3547,9 +3547,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.64.2" + "source": "https://github.com/utopia-php/database/tree/0.65.0" }, - "time": "2025-04-09T07:53:05+00:00" + "time": "2025-04-14T07:39:01+00:00" }, { "name": "utopia-php/domains", diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 44738b557c..1b3311b756 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -563,22 +563,19 @@ class Databases extends Action $start = \microtime(true); try { - $documents = $database->deleteDocuments($collectionId, $queries); + $count = $database->deleteDocuments( + $collectionId, + $queries, + Database::DELETE_BATCH_SIZE, + $callback + ); } catch (\Throwable $th) { $tenant = $database->getSharedTables() ? 'Tenant:'.$database->getTenant() : ''; Console::error("Failed to delete documents for collection:{$database->getNamespace()}_{$collectionId} {$tenant} :{$th->getMessage()}"); return; } - if (\is_callable($callback)) { - foreach ($documents as $document) { - $callback($document); - } - } - $end = \microtime(true); - $count = \count($documents); - Console::info("Deleted {$count} documents by group in " . ($end - $start) . " seconds"); } diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 5be865f42b..4a2cb60d32 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -1050,24 +1050,20 @@ class Deletes extends Action /** * deleteDocuments uses a cursor, we need to add a unique order by field or use default */ - try { - $documents = $database->deleteDocuments($collection, $queries); + $count = $database->deleteDocuments( + $collection, + $queries, + Database::DELETE_BATCH_SIZE, + $callback + ); } catch (Throwable $th) { $tenant = $database->getSharedTables() ? 'Tenant:'.$database->getTenant() : ''; Console::error("Failed to delete documents for collection:{$database->getNamespace()}_{$collection} {$tenant} :{$th->getMessage()}"); return; } - if (\is_callable($callback)) { - foreach ($documents as $document) { - $callback($document); - } - } - $end = \microtime(true); - $count = \count($documents); - Console::info("Deleted {$count} documents by group in " . ($end - $start) . " seconds"); }