Commit c002ae63 authored by Taylor Otwell's avatar Taylor Otwell

Use constraints for "unique" on Postgres schemas.

Previous was using CREATE INDEX, should be using ADD CONSTRAINT as this will create the index automatically per Postgres documentation.
Signed-off-by: 's avatarTaylor Otwell <taylorotwell@gmail.com>
parent fba6c303
...@@ -146,7 +146,11 @@ class Postgres extends Grammar { ...@@ -146,7 +146,11 @@ class Postgres extends Grammar {
*/ */
public function unique(Table $table, Fluent $command) public function unique(Table $table, Fluent $command)
{ {
return $this->key($table, $command, true); $table = $this->wrap($table);
$columns = $this->columnize($command->columns);
return "ALTER TABLE $table ADD CONSTRAINT ".$command->name." UNIQUE ($columns)";
} }
/** /**
...@@ -283,7 +287,7 @@ class Postgres extends Grammar { ...@@ -283,7 +287,7 @@ class Postgres extends Grammar {
*/ */
public function drop_unique(Table $table, Fluent $command) public function drop_unique(Table $table, Fluent $command)
{ {
return $this->drop_key($table, $command); return "ALTER TABLE ".$this->wrap($table)." DROP CONSTRAINT ".$command->name;
} }
/** /**
......
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