Question

I have a application, running with MySQL in my local machine. There is a field I define as boolean in Rails, which is represent in 0 or 1 in MySQL.

I am now trying migrate to Heroku, which is using PostgreSQL. After push the code and database to Heroku, the app cannot run.

There is an error message.

ActiveRecord::StatementInvalid (PGError: ERROR:  operator does not exist: boolean = integer

How can I fix it?

Thanks all.

Was it helpful?

Solution

That's because MySQL uses TinyInt(1) for storing boolean attributes where as PostgreSQL has a native boolean type.

It's better to use a migration tool like

https://github.com/maxlapshin/mysql2postgres

which takes care of handling these problems.

Setup a local postgres database. Migrate from MySQL to your local Postgres DB. Then push from your local postgres DB to Heroku using taps.

Also, make sure you have not used 'y' or 'n' anywhere in the code, since these values are specific to MySQL

UPDATE: Before you do any of the above, check out this http://devcenter.heroku.com/articles/database#common_issues_migrating_to_postgresql

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top