带有长文本的 Rails 3 迁移

编程入门 行业动态 更新时间:2024-10-24 14:20:53
本文介绍了带有长文本的 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 => 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 迁移

本文发布于:2023-10-29 03:30:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538597.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!