mike zaby
mike zaby

Reputation: 488

Heroku, cant push my db

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 have try to push with

heroku db:push

or with

heroku db:push mysql2://root:[email protected]/damp?encoding=utf8

What can i do to fix this?

Upvotes: 1

Views: 500

Answers (2)

mu is too short
mu is too short

Reputation: 434585

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

Upvotes: 0

roboles
roboles

Reputation: 886

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.

Upvotes: 1

Related Questions