Skip to content

Fix for index names #1137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2017
Merged
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
14 changes: 9 additions & 5 deletions src/Jenssegers/Mongodb/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
/**
* The MongoConnection object for this blueprint.
*
* @var MongoConnection
* @var \Jenssegers\Mongodb\Connection
*/
protected $connection;

/**
* The MongoCollection object for this blueprint.
*
* @var MongoCollection
* @var \Jenssegers\Mongodb\Collection|\MongoDB\Collection
*/
protected $collection;

Expand All @@ -32,7 +32,7 @@ public function __construct(Connection $connection, $collection)
{
$this->connection = $connection;

$this->collection = $connection->getCollection($collection);
$this->collection = $this->connection->getCollection($collection);
}

/**
Expand All @@ -54,6 +54,10 @@ public function index($columns = null, $name = null, $algorithm = null, $options
$columns = $transform;
}

if ($name !== null) {
$options['name'] = $name;
}

$this->collection->createIndex($columns, $options);

return $this;
Expand All @@ -64,7 +68,7 @@ public function index($columns = null, $name = null, $algorithm = null, $options
*/
public function primary($columns = null, $name = null, $algorithm = null, $options = [])
{
return $this->unique($columns, $options);
return $this->unique($columns, $name, $algorithm, $options);
}

/**
Expand Down Expand Up @@ -102,7 +106,7 @@ public function unique($columns = null, $name = null, $algorithm = null, $option

$options['unique'] = true;

$this->index($columns, null, null, $options);
$this->index($columns, $name, $algorithm, $options);

return $this;
}
Expand Down