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: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
@@ -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 {
|
|||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user