DB: postgres
$table = $this->table('test_table')
->addColumn('test_field', 'string', array('limit' => 10))
->save();
$this->execute("ALTER TABLE ONLY test
ADD CONSTRAINT test_key UNIQUE (test_field);");
Has a method to add unique index. But could not see a method to add constraint, so i am doing a separate alter table to do it. Is there a method to add unique constraint?
Yep, I guess what you are looking for is..
$table->addIndex('column-name', array('unique' => true))
I think addIndex is not what sooners87 is looking for...
He is looking for a method to add constraint, not index.
:+1: for this feature!
ADD CONSTRAINT is essential.
"CREATE INDEX" is different of "ADD CONSTRAINT".
Constraints have a name.
Most helpful comment
:+1: for this feature!
ADD CONSTRAINT is essential.
"CREATE INDEX" is different of "ADD CONSTRAINT".
Constraints have a name.