我有一个应用程序,在我的本地机器上运行 MySQL。有一个字段我在Rails中定义为boolean,在MySQL中用0或1表示。
我现在正在尝试迁移到使用 PostgreSQL 的 Heroku。将代码和数据库推送到Heroku后,应用无法运行。
有一条错误信息。
ActiveRecord::StatementInvalid (PGError: ERROR: operator does not exist: boolean = integer
我该如何解决?
谢谢大家。
最佳答案
那是因为 MySQL 使用 TinyInt(1) 来存储 bool 属性,而 PostgreSQL 具有 native bool 类型。
最好使用像这样的迁移工具
https://github.com/maxlapshin/mysql2postgres
负责处理这些问题。
设置本地 postgres 数据库。从 MySQL 迁移到本地 Postgres 数据库。然后使用 taps 从本地 postgres 数据库推送到 Heroku。
此外,请确保您没有在代码中的任何地方使用“y”或“n”,因为这些值特定于 MySQL
更新:在您执行上述任何操作之前,请查看此 http://devcenter.heroku.com/articles/database#common_issues_migrating_to_postgresql
关于mysql - 如何将 MySQL 中的 bool 字段迁移到 Heroku 中的 PostgreSQL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7163331/