문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top