Rails 4 - postgresql 9.4 jsonb不存在

Kar*_*ick 8 postgresql ruby-on-rails-4 jsonb

我在我的项目中使用了rails 4和postgresql 9.4.当我运行"rdd && rdc && rdm && rds"时我得到了这个错误PG :: UndefinedObject:错误:类型"jsonb"不存在如何解决这个错误?告诉我.

我的迁移文件:

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
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助!

ste*_*tef 7

检查您是否已连接到正在开发的Postgres实例.

rails console
ActiveRecord::Base.connection.execute("select version();").first["version"]
Run Code Online (Sandbox Code Playgroud)

如果您确定运行的是9.4,那么可能是您运行了两台Postgres服务器.一个9.4,一个较旧的.

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