Rails 3 Migration with longtext

前端 未结 1 840
刺人心
刺人心 2020-12-04 06:45

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

相关标签:
1条回答
  • 2020-12-04 07:33

    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.

    0 讨论(0)
提交回复
热议问题