Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 + PostgreSQL hstore, can't execute "CREATE EXTENSION hstore"

I have RubyOnRails 4.1.4 and PostgreSQL installed on my MacOS X by:

brew install postgresql

When I'm trying to migrate this one:

CREATE EXTENSION hstore

It gives out me an error:

PG::UndefinedFile: ERROR:  could not open extension control file "/usr/share/postgresql/9.3/extension/hstore.control": No such file or directory

I tried to find "hstore.control" in filesystem using:

find / -name "hstore.control"

And found out that this file is located in the different path:

usr/local/Cellar/postgresql/9.3.4/share/postgresql/extension/hstore.control

So how can I redefine "PG" gem's configuration to correct the path of the hstore extension? I just tried to remove the gem and install it with:

rvm all do gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.4/bin/pg_config

But it didn't work. I still have the same error.

Thank you in advance.

UPDATE:

I just created symlink to correct path, but anyway it gives me out the same error.

like image 816
kuatro Avatar asked Jul 10 '14 06:07

kuatro


2 Answers

The solution is simple, just install postgresql-contrib in your OS and then run the migration as it is shown here Rails 4 PostgreSQL integration or any other way you using. For example if you are using ubuntu it will be:

sudo apt-get install postgresql-contrib-X.X

where X.X is the postgresql version that you are using. If it is version 9.3 it be:

sudo apt-get install postgresql-contrib-9.3

I also think for MAC Os is almost same, only that you will use brew.

like image 146
ben Avatar answered Oct 10 '22 01:10

ben


This link helped me out. We need to install postgresql-contrib before trying to create a HStore extension.

https://gist.github.com/terryjray/3296171

like image 30
Sri Murthy Upadhyayula Avatar answered Oct 10 '22 01:10

Sri Murthy Upadhyayula