Forum: Ruby on Rails Unique Boolean Condition Constraint

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B4084fdc8c0512d3402387a87b008035?d=identicon&s=25 Preston Lee (Guest)
on 2007-04-05 02:15
(Received via mailing list)
I'd like to add a unique constraint (via add_index or something
similar) in a migration which works off two columns, one of which is
boolean and must be true for the constraint to hold. Something like..

         add_index :my_table, [:some_integer_column,
{:some_boolean_column => true}], :unique => true

..but of course this doesn't work. Is there a "correct" way of doing
this without writing the raw SQL?

This topic is locked and can not be replied to.