【问题标题】:Rails 4 - postgresql 9.4 jsonb does not existRails 4 - postgresql 9.4 jsonb 不存在
【发布时间】:2015-02-27 09:34:36
【问题描述】:

我在我的项目中使用了 rails 4 和 postgresql 9.4。当我运行 "rdd && rdc && rdm && rds" 时,我得到了这个错误 PG::UndefinedObject: ERROR: type "jsonb" does not exist 如何解决这个错误?告诉我。

我的迁移文件:

class CreateConsultingLocationDoctorSchedules < ActiveRecord::Migration
   def change
      create_table :consulting_location_doctor_schedules do |t|
           t.belongs_to :consulting_location_doctor
           t.datetime :schedule_date, null: false
           t.jsonb :slot_details, index: true, default: {}
           t.daterange :start_and_end_time, null: false
           t.datetime :deleted_at
           t.belongs_to :deleted_by

           t.timestamps
      end
   end
end

感谢您的帮助!

【问题讨论】:

  • 这表明您的 Rails 版本实际上不是 4.2,因为至少您的格式是正确的,并且必要的版本是 Rails 的 4.2 和 PostgreSQL 的 9.4。你能仔细检查一下吗?
  • 我有同样的问题,我正在使用 rails 4.2 和 pg 9.4.1 你找到任何解决方案了吗??
  • 重复的问题和解决方法在这里:stackoverflow.com/questions/29393562/…

标签: postgresql ruby-on-rails-4 jsonb


【解决方案1】:

检查您是否连接到开发中的正确 Postgres 实例。

rails console
ActiveRecord::Base.connection.execute("select version();").first["version"]

如果您确定您运行的是 9.4,那么您可能有两个 Postgres 服务器正在运行。一个 9.4 和一个更旧的。

我遇到了这个问题并编辑了我的 database.yml 并指定了host: 'localhost'

【讨论】:

  • 在我的情况下,正确的 postgres 在 5433 端口上运行。
猜你喜欢
  • 2015-07-30
  • 1970-01-01
  • 2015-08-20
  • 1970-01-01
  • 1970-01-01
  • 2015-06-06
  • 2016-11-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多