Hi,
I'm using MySQL fulltext indexes in a Rails 2.3.2 App. I added the index via native SQL in my migration. But there is a known issue causing problems with the schema.rb. Rails doesn't understand fulltext indexes and tries to create a normal index. This will cause an error when creating the database from schema.rb (eg testing, specs, etc.):
Mysql::Error: BLOB/TEXT column 'text' used in key specification without a key length: CREATE INDEX `fulltext_sms` ON `sms` (`text`)
Is there a way to solve this issue in Rails 2.3.2 without monkey-patching Rails? And if not, what's the best way to deals with this?
Thank you!
My migration:
class FulltextIndexCustomersSmsMessage < ActiveRecord::Migration
def self.up
execute('ALTER TABLE sms ENGINE = MyISAM')
execute('ALTER TABLE customers ENGINE = MyISAM')
execute('CREATE FULLTEXT INDEX fulltext_sms ON sms (text(500))')
execute('CREATE FULLTEXT INDEX fulltext_customer ON customers (fullname(255))')
end
def self.down
execute('ALTER TABLE sms ENGINE = innodb')
execute('ALTER TABLE customers ENGINE = innodb')
execute('DROP INDEX fulltext_sms ON sms')
execute('DROP INDEX fulltext_customer ON customers')
end
end
schema.rb:
add_index "sms", ["text"], :name => "fulltext_sms"