本文介绍了带有长文本的 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 和 MySQL 的 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 => 4294967295limit 的默认值为 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 迁移
发布评论