I’m trying to figure out how to reliably define a column as mediumtext
type through a migration.
First I tried this:
change_column( :entries, :lines, :text, :limit => 2.megabytes )
It worked fine for my development box on MySQL 5.0, but when I tried
it on my production box with MySQL 4.0, it gave the following error:
MysqlError: You have an error in your SQL syntax. Check the manual
that corresponds to your MySQL server version for the right syntax to
use near ‘(2097152)’ at line 1: ALTER TABLE entries CHANGE lines lines
I finally settled on doing this in the migration:
execute “ALTER TABLE entries CHANGE COLUMN lines lines MEDIUMTEXT”
However, it makes me feel a little dirty and doesn’t reflect correctly
in the schema.rb
Is there a way to tell rails to do the migration in a way that’s
compatible with older versions of MySQL?