Rails 3 Migration with longtext

Ruby on-RailsMigrationRuby on-Rails-3

Ruby on-Rails Problem Overview


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

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondennismonsewiczView Question on Stackoverflow
Solution 1 - Ruby on-RailsChuck CallebsView Answer on Stackoverflow