views:

13

answers:

1

I have a table in a Mysql db that I want to use multicolumn indexing on. How can I do this in rails w/o using the mysql console?

+2  A: 

Inside a migration definition you can do it like this:

add_index :table_name, [:column1, :column2]

rspeicher
Yep, and occassionally the generated name will be too long and you'll need to add a `:name => 'my_index'` option.
Shadwell
It also takes the :unique option, which will speed up your queries a little bit if appropriate.
Raphomet