加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Heroku迁移:类型“bytea”不允许使用类型修饰

发布时间:2020-12-16 19:23:57 所属栏目:百科 来源:网络整理
导读:我在Heroku上运行了一些迁移,我遇到了这个问题.我在其中一个迁移中有这一行来创建一个新表: t.binary :file,:limit = 10.megabytes Heroku给了我这个PostgreSQL错误: An error has occurred,this and all later migrations canceled:PGError: ERROR: type
我在Heroku上运行了一些迁移,我遇到了这个问题.我在其中一个迁移中有这一行来创建一个新表:
t.binary :file,:limit => 10.megabytes

Heroku给了我这个PostgreSQL错误:

An error has occurred,this and all later migrations canceled:

PGError: ERROR:  type modifier is not allowed for type "bytea"
LINE 1: ..."file" bytea(10485760)...
                                                         ^
: CREATE TABLE "files" ("id" serial primary key,"file" bytea(10485760),"created_at" timestamp,"updated_at" timestamp)

如何更改我的迁移,以便它与MySQL和Postgre一起使用?

解决方法

来自Heroku的文档:

二进制字段限制

原因:PostgreSQL不限制二进制字段.使用:limit选项添加:binary字段的任何迁移都会引发语法错误.

解决方案:如果可能,请省略:二进制字段的限制 – 或者在运行之前测试数据库.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读