用longtext进行Rails 3迁移 [英] Rails 3 Migration with longtext
本文介绍了用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
类型,则可以处理MySQL的tinytext
,text
,mediumtext
和longtext
.只需使用: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文档>.
The MySQL documentation can be found here.
这篇关于用longtext进行Rails 3迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文