How does one create a Rails migration properly so that a table gets changed to MyISAM in MySQL? It is currently InnoDB. Running a raw execute statement will change the table, but it won’t update db/schema.rb, so when the table is recreated in a testing environment, it goes back to InnoDB and my fulltext searches fail.
How do I go about changing/adding a migration so that the existing table gets modified to MyISAM and schema.rb gets updated so my db and respective test db get updated accordingly?
I didn’t find a great way to do this. You could change your schema.rb like someone suggested and then run:
rake db:schema:load, however, this will overwrite your data.The way I did it was (assuming you are trying to convert a table called books):
Save the existing data from the CLI:
CREATE TABLE tmp SELECT * FROM books;In your new migration file, drop the books table and recreate it with
:options => "ENGINE=MyISAM"like someone said in the commentCopy the contents back:
INSERT INTO books SELECT * FROM tmp