diff --git a/app/config/collections/common.php b/app/config/collections/common.php index 2c80ba9ec7..e6ebfe643b 100644 --- a/app/config/collections/common.php +++ b/app/config/collections/common.php @@ -1540,15 +1540,6 @@ return [ ], ], 'indexes' => [ - // Mongodb do not allow two fulltext indexes on the same field in a single collection - // https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/text-index-restrictions/ - // [ - // '$id' => ID::custom('_fulltext_name'), - // 'type' => Database::INDEX_FULLTEXT, - // 'attributes' => ['name'], - // 'lengths' => [], - // 'orders' => [], - // ], [ '$id' => ID::custom('_key_search'), 'type' => Database::INDEX_FULLTEXT, @@ -1563,14 +1554,13 @@ return [ 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], - // Mongodb do not allow two indexes on the same field in a single collection - // [ - // '$id' => ID::custom('_key_name'), - // 'type' => Database::INDEX_KEY, - // 'attributes' => ['name'], - // 'lengths' => [], - // 'orders' => [Database::ORDER_ASC], - // ], + [ + '$id' => ID::custom('_key_name'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['name'], + 'lengths' => [], + 'orders' => [Database::ORDER_ASC], + ], [ '$id' => ID::custom('_key_fileSecurity'), 'type' => Database::INDEX_KEY, @@ -1779,15 +1769,6 @@ return [ 'lengths' => [], 'orders' => [Database::ORDER_ASC], ], - // Mongodb do not allow two fulltext indexes on the same field in a single collection - // https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/text-index-restrictions/ - // [ - // '$id' => ID::custom('_key_name'), - // 'type' => Database::INDEX_FULLTEXT, - // 'attributes' => ['name'], - // 'lengths' => [], - // 'orders' => [Database::ORDER_ASC], - // ], [ '$id' => ID::custom('_key_type'), 'type' => Database::INDEX_KEY, @@ -2055,16 +2036,8 @@ return [ 'filters' => ['topicSearch'], ], ], - // Mongodb do not allow two fulltext indexes on the same field in a single collection - // https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/text-index-restrictions/ + 'indexes' => [ - // [ - // '$id' => ID::custom('_key_name'), - // 'type' => Database::INDEX_FULLTEXT, - // 'attributes' => ['name'], - // 'lengths' => [], - // 'orders' => [], - // ], [ '$id' => ID::custom('_key_search'), 'type' => Database::INDEX_FULLTEXT, diff --git a/composer.json b/composer.json index e3558172ae..0913df6837 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "utopia-php/cache": "0.13.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-feat-mongo-tmp-pulls as 1.4.6", + "utopia-php/database": "dev-feat-mongo-inversion as 1.4.6", "utopia-php/detector": "0.1.*", "utopia-php/domains": "0.8.*", "utopia-php/dns": "0.3.*", diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php index 395e3d757b..253d7dab3b 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php @@ -113,7 +113,7 @@ class Upsert extends Action try { $modified = $dbForProject->withPreserveDates(function () use ($dbForProject, $database, $collection, $documents, $plan, &$upserted) { - return $dbForProject->createOrUpdateDocuments( + return $dbForProject->upsertDocuments( 'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documents, onNext: function (Document $document) use ($plan, &$upserted) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php index 54b1cad950..9aa138b31d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php @@ -243,7 +243,7 @@ class Upsert extends Action $upserted = []; try { $dbForProject->withPreserveDates(function () use (&$upserted, $dbForProject, $database, $collection, $newDocument) { - return $dbForProject->createOrUpdateDocuments( + return $dbForProject->upsertDocuments( 'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), [$newDocument], onNext: function (Document $document) use (&$upserted) { diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index da8c086bf4..1cd866e9a9 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -435,7 +435,7 @@ class StatsResources extends Action $message = 'Stats writeDocuments project: ' . $project->getId() . '(' . $project->getSequence() . ')'; try { - $dbForLogs->createOrUpdateDocuments( + $dbForLogs->upsertDocuments( 'stats', $this->documents ); diff --git a/src/Appwrite/Platform/Workers/StatsUsage.php b/src/Appwrite/Platform/Workers/StatsUsage.php index 3610381d5a..3a615072df 100644 --- a/src/Appwrite/Platform/Workers/StatsUsage.php +++ b/src/Appwrite/Platform/Workers/StatsUsage.php @@ -424,7 +424,7 @@ class StatsUsage extends Action try { $dbForProject = $getProjectDB($projectStats['project']); Console::log('Processing batch with ' . count($projectStats['stats']) . ' stats'); - $dbForProject->createOrUpdateDocumentsWithIncrease('stats', 'value', $projectStats['stats']); + $dbForProject->upsertDocumentsWithIncrease('stats', 'value', $projectStats['stats']); Console::success('Batch successfully written to DB'); unset($this->projects[$sequence]); @@ -468,7 +468,7 @@ class StatsUsage extends Action try { Console::log('Processing batch with ' . count($this->statDocuments) . ' stats'); - $dbForLogs->createOrUpdateDocumentsWithIncrease( + $dbForLogs->upsertDocumentsWithIncrease( 'stats', 'value', $this->statDocuments diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index 290865b809..b5800eac37 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -3,7 +3,6 @@ namespace Tests\E2E\General; use Appwrite\Platform\Modules\Compute\Specification; -use Appwrite\Tests\Retry; use CURLFile; use DateTime; use Tests\E2E\Client; @@ -714,7 +713,7 @@ class UsageTest extends Scope $response = $this->client->call( Client::METHOD_POST, - '/tablesdb/' . $databaseId . '/tables', + '/databases/' . $databaseId . '/tables', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'] @@ -743,7 +742,7 @@ class UsageTest extends Scope if ($i < (self::CREATE / 2)) { $response = $this->client->call( Client::METHOD_DELETE, - '/tablesdb/' . $databaseId . '/tables/' . $tableId, + '/databases/' . $databaseId . '/tables/' . $tableId, array_merge([ 'x-appwrite-project' => $this->getProject()['$id'] ], $this->getHeaders()), @@ -758,7 +757,7 @@ class UsageTest extends Scope $response = $this->client->call( Client::METHOD_POST, - '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/columns' . '/string', + '/databases/' . $databaseId . '/tables/' . $tableId . '/columns' . '/string', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'] @@ -781,7 +780,7 @@ class UsageTest extends Scope $response = $this->client->call( Client::METHOD_POST, - '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows', + '/databases/' . $databaseId . '/tables/' . $tableId . '/rows', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'] @@ -803,7 +802,7 @@ class UsageTest extends Scope if ($i < (self::CREATE / 2)) { $response = $this->client->call( Client::METHOD_DELETE, - '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows/' . $rowId, + '/databases/' . $databaseId . '/tables/' . $tableId . '/rows/' . $rowId, array_merge([ 'x-appwrite-project' => $this->getProject()['$id'] ], $this->getHeaders()), @@ -899,7 +898,7 @@ class UsageTest extends Scope $response = $this->client->call( Client::METHOD_GET, - '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/usage?range=30d', + '/databases/' . $databaseId . '/tables/' . $tableId . '/usage?range=30d', $this->getConsoleHeaders() ); @@ -1291,7 +1290,7 @@ class UsageTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'domain' => 'test-' . ID::unique() . '.' . System::getEnv('_APP_DOMAIN_FUNCTIONS'), + 'domain' => 'test-' . ID::unique() . System::getEnv('_APP_DOMAIN_FUNCTIONS'), 'functionId' => $functionId, ], ); diff --git a/tests/e2e/Services/Databases/Legacy/DatabasesBase.php b/tests/e2e/Services/Databases/Legacy/DatabasesBase.php index 2cc363fc23..62d25b506c 100644 --- a/tests/e2e/Services/Databases/Legacy/DatabasesBase.php +++ b/tests/e2e/Services/Databases/Legacy/DatabasesBase.php @@ -5909,6 +5909,11 @@ trait DatabasesBase public function testSpatialPointAttributes(): void { + + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -6047,6 +6052,11 @@ trait DatabasesBase public function testSpatialLineAttributes(): void { + + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -6184,6 +6194,11 @@ trait DatabasesBase public function testSpatialPolygonAttributes(): void { + + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -6319,6 +6334,11 @@ trait DatabasesBase public function testSpatialAttributesMixedCollection(): void { + + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -6473,6 +6493,11 @@ trait DatabasesBase public function testUpdateSpatialAttributes(): void { + + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -6632,6 +6657,11 @@ trait DatabasesBase public function testSpatialQuery(): void { + + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -7043,6 +7073,10 @@ trait DatabasesBase public function testSpatialRelationshipOneToOne(): void { + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -7181,6 +7215,10 @@ trait DatabasesBase public function testSpatialRelationshipOneToMany(): void { + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -7315,6 +7353,11 @@ trait DatabasesBase public function testSpatialRelationshipManyToOne(): void { + + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -7440,6 +7483,10 @@ trait DatabasesBase public function testSpatialRelationshipManyToMany(): void { + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -7565,6 +7612,11 @@ trait DatabasesBase public function testSpatialIndex(): void { + + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -7675,6 +7727,11 @@ trait DatabasesBase public function testSpatialDistanceInMeter(): void { + + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], diff --git a/tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php index e8c1d89db4..e67018f9c1 100644 --- a/tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php @@ -6203,6 +6203,10 @@ class DatabasesCustomServerTest extends Scope public function testSpatialBulkOperations(): void { + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + // Create database $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json', @@ -6604,6 +6608,10 @@ class DatabasesCustomServerTest extends Scope public function testSpatialBulkOperationsWithLineStrings(): void { + if($this->isMongoDB()) { + $this->markTestSkipped('MongoDB is not supported for this test'); + } + // Create database $database = $this->client->call(Client::METHOD_POST, '/databases', [ 'content-type' => 'application/json',