How to create an index for a TEXQ mysql column using rails 3?

advertisements

How to create a index for an mysql column using rails 3?

According to this

When you index a BLOB or TEXT column, you must specify a prefix length for the index.

How can i achieve the same using Rails 3


In the migration you could do:

add_index(:table_name, :column_name, :length => 10)

http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_index - for more details