Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error - type "json" does not exist - in Postgresql during rake db migrate

I have recently cloned a project to my local Ubuntu box now that I am remote, and upon rake db migrate, I get the following error:

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

A couple columns in my tables that are:

add_column :table, :column, :json

This migration works on the Macs at work, but are not working here. I have tried upgrading to PostgreSQL 9.3.4, but the issue still persists. I also tried sudo apt-get upgrade postgresql, and still the problem persists.

Ruby version is 2.1.0 Rails version is 4.0.3

like image 957
earth2jason Avatar asked Jul 06 '14 21:07

earth2jason


2 Answers

I have tried upgrading to PostgreSQL 9.3.4, but the issue still persists

Most likely you're still connecting to the old version. Try SELECT version().

Since you mention apt-get you're presumably on Debian or Ubuntu. These use pg_wrapper to allow multiple PostgreSQL installs in parallel. Each one gets a different port number. The first install gets the default port 5432. Subsequent installs get higher ports.

You can view the installs with pg_lsclusters. Most likely your 9.3 install is on port 9433, and you need to change your database.yml (since you're using Rails) to connect to that port.

like image 130
Craig Ringer Avatar answered Nov 13 '22 19:11

Craig Ringer


If for any reason you run into this issue, your 9.3 version is not actually running.

I found this link to very helpful:

http://nixmash.com/postgresql/upgrading-postgresql-9-1-to-9-3-in-ubuntu/

I started with the command:

sudo service postgresql stop

and ran all the commands from there. Everything works fine now.

like image 28
earth2jason Avatar answered Nov 13 '22 21:11

earth2jason