views:

37

answers:

2

I thought this mus have been answered before, but I didn't find any pointer from my searches. May be I tried with wrong key words.

What I need is a migration to apply unique constraint to a combination of columns.

i.e.

for a Person table a combination of Firstname, LastName and Dob should be unique.

+2  A: 

Hi You may add unique index in your migration to the columns for example

add_index(:accounts, [:branch_id, :party_id], :unique => true)

or separate unique indexes for each column

Bohdan Pohorilets
For me it didn't work. I will update the question with more information.
rangalo
Sorry, it worked, first I tried by editing and existing migration which didn't work, then added a new one and it worked, thanks.
rangalo
+2  A: 

add_index :people, [:firstname, :lastname, :dob], :unique => true

rspeicher