6

I forked a repo from someone I'm collaborating with, and I'm just trying to get my development environment up and running. One of the migrations has a json attribute and we're using Postgres for both dev and production:

class CreateExams < ActiveRecord::Migration
  def change
    create_table :exams do |t|
      t.belongs_to :user
      t.json :exam
      t.timestamps
    end
  end
end

database.yml

development:
  adapter: postgresql
  database: examgen_development
  host: localhost

When I run the rake db:migrate, I get an error that would lead me to believe that PG doesn't support JSON column types:

PG::Error: ERROR:  type "json" does not exist

But I know Postgres 9.2 supports JSON (i.e. http://www.postgresql.org/docs/devel/static/datatype-json.html).

Interestingly, when I check the version of PG I'm using with 'psql' it shows 9.0.4. Whereas when I use 'postgres' it shows 9.2.1. So I'm not exactly sure what version I'm using and how to go about switching back and forth.

psql --version
psql (PostgreSQL) 9.0.4

postgres --version
postgres (PostgreSQL) 9.2.1

Does anyone have thoughts as to why I'm getting that Postgres error?

12
  • How did you install postgres, through brew? Commented Jul 26, 2013 at 21:43
  • Yup - I installed it a while ago w/ homebrew Commented Jul 26, 2013 at 21:44
  • Try to update it, brew doctor -> brew update -> brew upgrade postgresql, then try to see if your version are updated. Commented Jul 26, 2013 at 21:45
  • upon running 'brew upgrade postgresql' I get 'Error: postgresql-9.2.1 already installed' Commented Jul 26, 2013 at 21:52
  • You ran "brew update" then "brew upgrade postgresql"? I am on version postgresql-9.2.4 Commented Jul 26, 2013 at 21:53

1 Answer 1

7

OK, so it turns out at one point I had installed postgres via homebrew, and had also done so with Postgres.app at a different time. I began to realize this by checking the version of 'psql' and 'postgres' and noticed the distinction.

psql --version
psql (PostgreSQL) 9.0.4

postgres --version
postgres (PostgreSQL) 9.2.4

I uninstalled Postgres.app using their documentation here and then using homebrew ensured I was using the most recent version of postgres.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.