While trying to install Discourse on my laptop (Ubuntu 16.04) using this guide, I got some errors like this:
PG::InsufficientPrivilege: ERROR: permission denied to create extension "hstore"
and:
rails aborted!
ActiveRecord::NoDatabaseError: FATAL: database "discourse_test_multisite" does not exist
I got rid of the errors by changing this:
# Postgresql
sudo su postgres
createuser --createdb --superuser -Upostgres $(cat /tmp/username)
psql -c "ALTER USER $(cat /tmp/username) WITH PASSWORD 'password';"
psql -c "create database discourse_development owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -d discourse_development -c "CREATE EXTENSION hstore;"
psql -d discourse_development -c "CREATE EXTENSION pg_trgm;"
exit
to this:
# Postgresql
sudo su - postgres
createuser --createdb --superuser -Upostgres $(cat /tmp/username)
psql -c "ALTER USER $(cat /tmp/username) WITH PASSWORD 'password';"
psql -c "create database discourse_development owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -c "create database discourse_test_multisite owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
psql -d discourse_development -c "CREATE EXTENSION hstore;"
psql -d discourse_development -c "CREATE EXTENSION pg_trgm;"
psql -d discourse_test -c "CREATE EXTENSION hstore;"
psql -d discourse_test -c "CREATE EXTENSION pg_trgm;"
psql -d discourse_test_multisite -c "CREATE EXTENSION hstore;"
psql -d discourse_test_multisite -c "CREATE EXTENSION pg_trgm;"
exit
Diff:
2c2
< sudo su postgres
---
> sudo su - postgres
6a7
> psql -c "create database discourse_test_multisite owner $(cat /tmp/username) encoding 'UTF8' TEMPLATE template0;"
8a10,13
> psql -d discourse_test -c "CREATE EXTENSION hstore;"
> psql -d discourse_test -c "CREATE EXTENSION pg_trgm;"
> psql -d discourse_test_multisite -c "CREATE EXTENSION hstore;"
> psql -d discourse_test_multisite -c "CREATE EXTENSION pg_trgm;"
I’m too new to Rails/Discourse to know if it’s just my laptop or if I should add them to the docs, but I’ll leave the fix here in case someone else finds it useful.
(If it’s something that should go in the docs, let me know and I could make a pull request.)