Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 603
sscirrus Avatar asked Feb 12 '11 04:02

sscirrus


1 Answers

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.

like image 193
sscirrus Avatar answered Sep 22 '22 11:09

sscirrus