我有一个应用程序,使用rails作为一个API和烬作为前端(使用成员-rails宝石)。
在我的本地机器上,无论是在生产上还是在开发上,一切都是完美的。然而,每次在部署应用程序之后运行heroku run rake db:migrate时,我都会收到以下错误:
PG::UndefinedObject: ERROR: type "json" does not exist
它正在失败的迁移是:
class AddProjectimageToImages < ActiveRecord::Migration
def change
add_column :images, :project_image, :json
end
end有人知道heroku为什么不接受JSON类型吗?
烬在很大程度上依赖于在从API接收JSON时设置正确的格式,所以如果可能的话,我非常希望保留JSON类型。
发布于 2015-01-19 15:53:30
在postgresql < 9.2中不支持JSON数据类型
因此,您有两个选择:
1) (推荐)通过以下heroku教程将PG版本升级到(至少) 9.2:https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases
2)将JSON存储到text数据类型中,如果不使用任何postgresql函数,可能就足够了。然后,您可以在模型中使用serialize,这将在保存activerecord模型时处理转换:
class Image < ActiveRecord::Base
serialize :project_images, JSON
end为了防止这类问题,我强烈建议确保您的不同环境(dev/暂存/prod)使用您需要的任何软件的相同版本。
https://stackoverflow.com/questions/28027863
复制相似问题