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:
Taylor Otwell 2012-03-02 09:54:43 -06:00
parent fba6c303ea
commit c002ae6337
1 changed files with 6 additions and 2 deletions

View File

@ -146,7 +146,11 @@ public function primary(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)
{
return $this->drop_key($table, $command);
return "ALTER TABLE ".$this->wrap($table)." DROP CONSTRAINT ".$command->name;
}
/**