Forum: Ruby on Rails Using Migrations to Build a MySQL FULLTEXT index?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Michael G. (Guest)
on 2006-03-04 18:53
(Received via mailing list)
Can anyone point me to the proper syntax to build a FULLTEXT MySQL
index via migrations?

I'm really liking these things, and don't want to step back into the
world of manual intervention.
Damon C. (Guest)
on 2006-03-05 21:12
Michael G. wrote:
> Can anyone point me to the proper syntax to build a FULLTEXT MySQL
> index via migrations?
>
> I'm really liking these things, and don't want to step back into the
> world of manual intervention.

def self.up
  execute "your index sql goes here"
end

Since FULLTEXT indexes are most likely implemented differently across
different servers, it is difficult for Schema to support them in a
database agnostic way.  So, I think this is a case where the "easy
solution" is to just use SQL.  A more long term solution may be to patch
Rails (either through a plugin or a real patch) to support a wider
variety of data types.

-damon
http://damonclinkscales.com/
Alain R. (Guest)
on 2006-03-15 14:27
(Received via mailing list)
Michael,

   > Can anyone point me to the proper syntax to build a FULLTEXT MySQL
   > index via migrations?

I had - almost a  - success this morning with this migration :

  def self.up
        create_table "entity_extras" ,:options => "TYPE=MyISAM" do |t|
            t.column :entity_id     , :integer
            t.column :extra         , :text
        end
       execute "ALTER TABLE entity_extras ADD FULLTEXT(extra)"
 end

I said "almost" because it worked fine outside of Rails (a match query
would work in an external sql console, but it would prevent my unit
test from running and throw an 1170 error.

Mysql error: BLOB column 'extra' used in key specification without a key
length
http://www.mysqlfreaks.com/errors/275.php

I could make it work with
   :string
but not with
   :text
!!


I'll try again next week..

Alain
This topic is locked and can not be replied to.