On Feb 24, 2010, at 11:17 AM, Jarl Friis wrote:

Hi.

This must be the most obvious thing to do, but I just can't seem to
find examples of how to do this. I would like to create a table with a
table unique constraint on database level.

In deed some migration code that would generate the following SQL

CREATE TABLE properties (
 namespace CHAR(50),
 name      CHAR(50),
 value     VARCHAR(100),
 CONSTRAINT my_constraint UNIQUE (namespace, name)
);


create_table :properties.....
  .....
end

add_index :properties, [:namespace, :name], :unique => true




Jarl

-- 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 rubyonrails- [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 .


--
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.

Reply via email to