开发者

Heroku migration: type modifier is not allowed for type "bytea"

开发者 https://www.devze.com 2023-02-10 15:06 出处:网络
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:

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 TABL开发者_运维百科E "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.

0

精彩评论

暂无评论...
验证码 换一张
取 消