Ruby-on-rails 使用长文本进行 Rails 3 迁移
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4443477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rails 3 Migration with longtext
提问by dennismonsewicz
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.
我需要在 Rails 脚本中将列类型从文本更改为长文本,但找不到有关如何执行此操作的任何信息。
Has anyone ran across this?
有没有人遇到过这个?
Thanks! Dennis
谢谢!丹尼斯
回答by Chuck Callebs
The texttype handles tinytext, text, mediumtext, and longtextfor MySQL, if that's what you're using. Just specify the upper bound using :limit => ...
该text型手柄tinytext,text,mediumtext,和longtextMySQL的,如果这就是你使用的是什么。只需使用指定上限:limit => ...
Example:
例子:
change_column :articles, :body, :text, :limit => 4294967295
The default value of limitis 65535, as expected.
limit正如预期的那样,默认值为65535。
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.
MySQL 文档可以在这里找到。

