# MediumText with Rails Migrations

**URL:** <https://www.ruby-forum.com/t/mediumtext-with-rails-migrations/64913>\
**Category:** Rails\
**Created:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/mediumtext-with-rails-migrations/64913 "2006-08-15T14:20:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![makenai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@makenai](https://www.ruby-forum.com/u/makenai)\
**Post date:** [August 15, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/mediumtext-with-rails-migrations/64913/1 "2006-08-15T14:20:19Z")

</div>

Hi,

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  
text(2097152)

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?

Thanks!

-Pawel
