Yeah that's true, thanks.

Steve

On Tue, Oct 13, 2009 at 9:17 AM, Marnen Laibow-Koser <
[email protected]> wrote:

>
> Colin Law wrote:
> > 2009/10/13 steveb56 <[email protected]>:
> >> add_index(:friendships, [:friend_id1, :friend_id2], :unique => true)
> >>
> >> I would also like to add an index to take care of the following
> >> situation...
> >>
> >> id1  id2
> >> 1    2
> >> 2    1   # Error, since it's the same as the first record
> >
> > Could you setup your code so that for a friendship record id1 is
> > always less than id2?  If there is no way in the code that id1=2 and
> > id2=1 can occur then you do not need to protect against it.
>
> And if you really want to make this bulletproof, you can enforce id1 <
> id2 with a check constraint in the DB.
>
> >
> > Colin
>
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> [email protected]
> --
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to