earth2jason
earth2jason

Reputation: 717

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

Upvotes: 9

Views: 8851

Answers (2)

earth2jason
earth2jason

Reputation: 717

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.

Upvotes: 5

Craig Ringer
Craig Ringer

Reputation: 324501

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.

Upvotes: 19

Related Questions