Heroku迁移:类型修饰符不允许用于类型“bytea” [英] Heroku migration: type modifier is not allowed for type "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: Heroku is giving me this PostgreSQL error: How can I change my migration so it plays nice with both MySQL and Postgre? From Heroku's docs: 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屋!
t.binary :file, :limit => 10.megabytes
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)
Binary field limit