Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enabling hstore for new postgresql 9.1 and rails 3 install on ubuntu 12.04
RAILS_ENV=production rake db:setup
# produces the error below.....hmmm.....it's a no-worky
psql:/yourprojectpath/yourproject/db/structure.sql:29: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory
# hstore postgresql extension needs to be installed, so....
sudo apt-get install postgresql-contrib
# now your extension should be available to enable so log in with psql
psql -d yourproject_production -U yourdbuser -W
# in the psql shell
CREATE EXTENSION hstore;
\q
# now you're golden, may need to clean up and re-run
RAILS_ENV=production rake db:drop
RAILS_ENV=production rake db:setup
@Hengjie
Copy link

Hengjie commented Jan 27, 2013

Works fine here on Ubuntu 12.10

@taboularasa
Copy link

taboularasa commented Feb 5, 2013

I was having the same problem, Ubuntu 12.10 32 bit, rails 3, postgresql 9.1
confirming that this fix worked for me
thanks

@giedriusr
Copy link

giedriusr commented Feb 8, 2013

hm, I have issues with permissions.

# psql -d discourse_development -U root -W
Password for user root: 
psql (9.1.5, server 9.1.7)
Type "help" for help.

discourse_development=> CREATE EXTENSION hstore;
ERROR:  permission denied to create extension "hstore"
HINT:  Must be superuser to create this extension.

@giedriusr
Copy link

giedriusr commented Feb 8, 2013

Everything worked. thanks

@kirantpatil
Copy link

kirantpatil commented Apr 3, 2013

@rtdp
Copy link

rtdp commented Apr 15, 2013

worked for me too!

@fabrizioq
Copy link

fabrizioq commented May 15, 2013

@giedriusr I'm having the same permissions problem as you had. Could you tell me how you could get around them? Thanks in advance!

@tokhi
Copy link

tokhi commented May 23, 2013

I also had permission issue, I just log in to my DB via psql and then executed the below command:

CREATE EXTENSION hstore;

problem solved.^^

@waterlink
Copy link

waterlink commented Jul 4, 2013

Like a charm.. :)

@lccezinha
Copy link

lccezinha commented Jul 29, 2013

works fine for me PG 9.1 + Ubuntu 12.10, thanks!

@neilmarion
Copy link

neilmarion commented Aug 9, 2013

What I did was just

postgres# ALTER ROLE <user_name> SUPERUSER;

And that's it! Run migration again.

@drob
Copy link

drob commented Aug 21, 2013

Instead of opening up a psql shell, you can just run psql -c "CREATE EXTENSION hstore"

That lets you script this whole shebang.

@harryworld
Copy link

harryworld commented May 16, 2014

discourse project will need this

@nicolasgarnil
Copy link

nicolasgarnil commented Aug 14, 2014

Thanks

@scifisamurai
Copy link

scifisamurai commented Mar 12, 2015

I had the same permission issue on postgresql 9.4 on ubuntu 12.04 LTS. Doing the following worked:

sudo su postgres -c "psql db_name -c 'CREATE EXTENSION hstore;'"
I got this from: dokku-alt/dokku-alt#66

@zinwalin
Copy link

zinwalin commented Jun 19, 2015

@waterlink funny:)

@avdept
Copy link

avdept commented Feb 26, 2016

@scifisamurai, thanks, that helped me.

@bogdan8
Copy link

bogdan8 commented Sep 10, 2016

thanks

@alexventuraio
Copy link

alexventuraio commented Jan 24, 2018

I'm using Rails 5.0.2 and Postgres 9.5 on Ubuntu 16.04.3 LTS and what worked for me are the next two options:

First one:

- Install the extension with:
    sudo apt-get install postgresql-contrib
- Enable the extension in the corresponding Data Base:
    sudo su postgres -c "psql my_db_production -c 'CREATE EXTENSION hstore;'"

Second one:

- Install the extension with:
    sudo apt-get install postgresql-contrib
- Login as super user in Postgres
    sudo su - postgres
- Enter to your Data Base console:
    psql -d my_db_production -W
- In the psql shell run:
    CREATE EXTENSION hstore;
- Exit
    \q 

Now migrations run with out any error!
I hope it could be useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment