9

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

5
  • have you seen this: stackoverflow.com/questions/23284164/… Commented Jul 6, 2014 at 21:34
  • No. But the solution from that problem is how I have the schema currently set up. I also tried modifying application.rb as shown in the answers to no avail. Commented Jul 6, 2014 at 21:41
  • 2
    The json data type was introduced with Postgres 9.2. It should definitely work with v9.3.1. You did not disclose the actual version of the Postgres db cluster you are connecting to. What do you get for SELECT version()? Commented Jul 6, 2014 at 23:07
  • After upgrading PostgreSQL try to update the PG gem. Not sure if it can help but you could give it a try Commented Jul 6, 2014 at 23:29
  • Yes. So the command shows that 9.1 is online and 9.3 is down. Currently looking how to remedy that. Thanks! Commented Jul 7, 2014 at 19:42

2 Answers 2

19

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.

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

1 Comment

Actually, yes this helped me understand that 9.1 was online and not 9.3. 9.3 was down.
5

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.

1 Comment

For ubuntu 12.04 LTS - gist.github.com/mdpatrick/8895813 for upgrading from 9.1 to 9.3

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.