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
2010-09-29 21:03:53
Yep, and occassionally the generated name will be too long and you'll need to add a `:name => 'my_index'` option.
Shadwell
2010-09-29 21:17:31
It also takes the :unique option, which will speed up your queries a little bit if appropriate.
Raphomet
2010-09-29 21:24:08