Heroku迁移:类型修饰符不允许用于类型“bytea” [英] Heroku migration: type modifier is not allowed for type "bytea"

查看:723
本文介绍了Heroku迁移:类型修饰符不允许用于类型“bytea”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Heroku上运行一些迁移,并且遇到此问题。我在我的一个迁移中创建了一个新表:

  t.binary:file,:limit => 10.megabytes 

Heroku给我这个PostgreSQL错误:

 发生错误,此次以及所有后来的迁移都被取消:

PGError:错误:类型修饰符不允许输入bytea
LINE 1:...filebytea(10485760)...
^
:CREATE TABLEfiles(idserial primary key,filebytea(10485760), created_attimestamp,updated_attimestamp)

如何更改我的迁移, MySQL和Postgre?

解决方案

来自Heroku的文档: 限制

原因:PostgreSQL不限制二进制字段。任何使用:limit选项添加a:binary字段的迁移都会引发语法错误。解决方案:如果可能,省略二进制字段的限制 - 或在测试之前先测试数据库运行它。


I'm running some migrations on Heroku and I'm getting this issue. I have this line in one of my migrations to create a new table:

t.binary :file, :limit => 10.megabytes

Heroku is giving me this PostgreSQL error:

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) 

How can I change my migration so it plays nice with both MySQL and Postgre?

解决方案

From Heroku's docs:

Binary field limit

Cause: PostgreSQL doesn’t limit binary fields. Any migrations adding a :binary field with the :limit option will raise a syntax error.

Solution: Omit the :limit for binary fields if possible — or test the DB before running it.

这篇关于Heroku迁移:类型修饰符不允许用于类型“bytea”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆