I am trying to push my database to heroku, and get this error:
Taps Server Error: PGError: ERROR: invalid byte sequence for encoding "UTF8": 0x89
I am using mysql in my local db, and i have coding utf8 in application.rb. I h开发者_StackOverflow社区ave try to push with
heroku db:push
or with
heroku db:push mysql2://root:pasword@127.0.0.1/damp?encoding=utf8
What can i do to fix this?
Somewhere in your database there is a character that needs to be encoded in UTF-8, which isn't currently. I have had this bug in the past and the only solution is to find it out and change it. Painful if you have a large database.
In a comment you mention that you have binary images in your database. The error you're seeing:
Taps Server Error: PGError: ERROR: invalid byte sequence for encoding "UTF8": 0x89
is coming from some sort of text column, either varchar
or text
. In MySQL you want one of the BLOB types, in PostgreSQL you want a BYTEA
column, and in with ActiveRecord you want the binary
column type. Your table definition should look something like this:
create_table :your_table do |t|
#...
t.binary :image_column_name
#...
end
精彩评论