Commit db0c9525 authored by Jens Segers's avatar Jens Segers

Primary index is alias for unique index

parent fb23831b
...@@ -70,6 +70,18 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint { ...@@ -70,6 +70,18 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint {
return $this; return $this;
} }
/**
* Specify the primary key(s) for the table.
*
* @param string|array $columns
* @param array $options
* @return \Illuminate\Support\Fluent
*/
public function primary($columns = null, $options = array())
{
return $this->unique($columns, $options);
}
/** /**
* Indicate that the given index should be dropped. * Indicate that the given index should be dropped.
* *
......
...@@ -52,19 +52,38 @@ class SchemaTest extends TestCase { ...@@ -52,19 +52,38 @@ class SchemaTest extends TestCase {
{ {
Schema::collection('newcollection', function ($collection) Schema::collection('newcollection', function ($collection)
{ {
$collection->index('mykey'); $collection->index('mykey1');
}); });
$index = $this->getIndex('newcollection', 'mykey'); $index = $this->getIndex('newcollection', 'mykey1');
$this->assertEquals(1, $index['key']['mykey']); $this->assertEquals(1, $index['key']['mykey1']);
Schema::collection('newcollection', function ($collection)
{
$collection->index(['mykey2']);
});
$index = $this->getIndex('newcollection', 'mykey2');
$this->assertEquals(1, $index['key']['mykey2']);
Schema::collection('newcollection', function ($collection)
{
$collection->string('mykey3')->index();
});
$index = $this->getIndex('newcollection', 'mykey3');
$this->assertEquals(1, $index['key']['mykey3']);
}
public function testPrimary()
{
Schema::collection('newcollection', function ($collection) Schema::collection('newcollection', function ($collection)
{ {
$collection->index(['mykey']); $collection->string('mykey', 100)->primary();
}); });
$index = $this->getIndex('newcollection', 'mykey'); $index = $this->getIndex('newcollection', 'mykey');
$this->assertEquals(1, $index['key']['mykey']); $this->assertEquals(1, $index['unique']);
} }
public function testUnique() public function testUnique()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment