PG::InsufficientPrivilege: ERROR: permission denied to create extension "pgcrypto" HINT: Must be superuser to create this extension. : CREATE EXTENSION IF NOT EXISTS "pgcrypto"
Hi everyone, I have been deploying following the guides of this site. However, I had introduced the use of UUID and so I have set the use of extensions for PostgreSQL. Now, when I deploy, I get the following error:
PG::InsufficientPrivilege: ERROR: permission denied to create extension "pgcrypto"
HINT: Must be superuser to create this extension.
: CREATE EXTENSION IF NOT EXISTS "pgcrypto"
It's crear that I need to be superuser, but I gave superuser power to deploy user, and I wouldn't know what to do next. Any help on that? Thanks
For anyone having this issue in 2020, the problem is that the user deploy
was not created with SUPERUSER privileges which are required to create/enable extensions in Postgres.
In order to solve that, you have to give this privilege to the user deploy
by doing the following:
1 - ssh root@machine-address
2 - sudo su - postgres
3 - psql
4 - ALTER ROLE deploy SUPERUSER;
5 - \q
6 - exit
Now, re-run the deployment command: bundle exec cap production deploy
and it should work.
If you wan't to revoke the SUPERUSER privilate later for the deploy
user, repeat steps 1 to 6 above, replacing step for by:
ALTER ROLE deploy NOSUPERUSER;
I hope this helps someone :)