Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 Migration with longtext

I am needing to change a column type from text to longtext in my Rails script, but can't find anything on how to do this.

Has anyone ran across this?

Thanks! Dennis

like image 281
dennismonsewicz Avatar asked Dec 14 '10 19:12

dennismonsewicz


1 Answers

The text type handles tinytext, text, mediumtext, and longtext for MySQL, if that's what you're using. Just specify the upper bound using :limit => ...

Example:

change_column :articles, :body, :text, :limit => 4294967295

The default value of limit is 65535, as expected.

1 to 255 bytes: TINYTEXT
256 to 65535 bytes: TEXT
65536 to 16777215 bytes: MEDIUMTEXT
16777216 to 4294967295 bytes: LONGTEXT

The MySQL documentation can be found here.

like image 79
Chuck Callebs Avatar answered Oct 14 '22 13:10

Chuck Callebs