Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 - postgresql 9.4 jsonb does not exist

I have used rails 4 and postgresql 9.4 in my project.when i was run "rdd && rdc && rdm && rds" and i got this error PG::UndefinedObject: ERROR: type "jsonb" does not exist how do solve this error? tell me.

My migrate file:

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

Thanks for ur help!

like image 266
Karthick Avatar asked Dec 31 '14 09:12

Karthick


1 Answers

Check that you are connected to the right Postgres instance in development.

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

If you're sure you are running 9.4, then it might be that you have two Postgres servers running. One 9.4, and an older one.

I ran into this problem and edited my database.yml and specified host: 'localhost'.

like image 172
stef Avatar answered Oct 24 '22 14:10

stef