Robert Walker wrote:
> Example:
>
> CREATE TABLE properties (
> namespace CHAR(50),
> name CHAR(50),
> value VARCHAR(100),
> );
> execute <<-SQL
> ALTER TABLE products
> ADD CONSTRAINT my_constraint UNIQUE (namespace, name)
> SQL
Oops, I didn't notice your original post was not in migration syntax:
Better example:
def self.up
create_table :products do |t|
t.references :category
end
#add unique constraint
execute <<-SQL
ALTER TABLE products
ADD CONSTRAINT my_constraint UNIQUE (namespace, name)
SQL
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.