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
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With