Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions src/Database/Database.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/Database/Base.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -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());
Expand Down