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:
parent
fba6c303ea
commit
c002ae6337
|
@ -146,7 +146,11 @@ public function primary(Table $table, Fluent $command)
|
||||||
*/
|
*/
|
||||||
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 @@ public function drop_primary(Table $table, Fluent $command)
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue