Question

I am building up a rails application that I cloned from my friend. I am using Ubuntu 13.10, rails 3.2.14. I am using a postgresql database and when I try to run rake db:migrate it gives me some error like this:

PG::UndefinedObject: ERROR: type "json" does not exist
LINE 1: ALTER TABLE "filters" ADD COLUMN "search_string" json

I installed pg version :- 9.3.1

running rails db output is :-psql (9.3.1, server 9.1.10)

running select version(); :-PostgreSQL 9.1.10 on i686-pc-linux-gnu

Why is it showing psql -version different from the version connected to my database??

My friend is working on 9.2.4 I don't know why this error is occurring, I tried several times to downgrade using purge or remove commands to remove 9.3.1 all goes well but when I check psql --version it again shows me 9.3.1 . Any solution ???

Was it helpful?

Solution

The psql is a client tool that comes in a different package than the PostgreSQL server. That's why they can be at a different version level.

Presumably you have the postgresql-9.1 package for the server and postgresql-client-9.3 package for the client (which includes psql).

If you run as a shell command:

$ COLUMNS=200 dpkg -l 'postgres*'

it will display the list of all postgres packages with their full names, versions and status. On that basis you can find out what needs to be installed or uninstalled.

The PostgreSQL version that is bundled with Ubuntu-13.10 is 9.1. The JSON type does not exist in 9.1, it appeared in 9.2, so you want to upgrade either to 9.2 or 9.3.

To upgrade to a new PostgreSQL version, the recommended way is now through the pgdg repository maintained by the postgresql.org people.

See instructions at https://wiki.postgresql.org/wiki/Apt

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top