diff --git a/src/Database/Database.php b/src/Database/Database.php index 4029f46b01..10e094a253 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -230,16 +230,7 @@ public function create(): bool ['indexesInQueue', self::VAR_STRING, 1000000, false], ]); - /** @var Document[] $indexes*/ - $indexes = [ - new Document([ - '$id' => '_key_1', - 'type' => self::INDEX_UNIQUE, - 'attributes' => ['name'], - ]) - ]; - - $this->createCollection(self::COLLECTIONS, $attributes, $indexes); + $this->createCollection(self::COLLECTIONS, $attributes); return true; } diff --git a/tests/Database/Base.php b/tests/Database/Base.php index d517186f82..f64715ed05 100644 --- a/tests/Database/Base.php +++ b/tests/Database/Base.php @@ -64,6 +64,15 @@ public function testCreateListDeleteCollection() $this->assertCount(1, static::getDatabase()->listCollections()); + // Collection names should not be unique + $this->assertInstanceOf('Utopia\Database\Document', static::getDatabase()->createCollection('actors2')); + $this->assertCount(2, static::getDatabase()->listCollections()); + $collection = static::getDatabase()->getCollection('actors2'); + $collection->setAttribute('name', 'actors'); // change name to one that exists + $this->assertInstanceOf('Utopia\Database\Document', static::getDatabase()->updateDocument($collection->getCollection(), $collection->getId(), $collection)); + $this->assertEquals(true, static::getDatabase()->deleteCollection('actors2')); // Delete collection when finished + $this->assertCount(1, static::getDatabase()->listCollections()); + $this->assertEquals(false, static::getDatabase()->getCollection('actors')->isEmpty()); $this->assertEquals(true, static::getDatabase()->deleteCollection('actors')); $this->assertEquals(true, static::getDatabase()->getCollection('actors')->isEmpty());