使用长文本进行 Rails 3 迁移 [英] Rails 3 Migration with longtext
本文介绍了使用长文本进行 Rails 3 迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在 Rails 脚本中将列类型从文本更改为长文本,但找不到有关如何执行此操作的任何信息.
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.
有人遇到过这个吗?
谢谢!丹尼斯
推荐答案
text
类型处理tinytext
、text
、mediumtext
和 longtext
用于 MySQL,如果这是您使用的.只需使用 :limit => 指定上限即可....
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 => ...
示例:
change_column :articles, :body, :text, :limit => 4294967295
limit
的默认值为 65535,符合预期.
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
可以在此处找到 MySQL 文档.
这篇关于使用长文本进行 Rails 3 迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文