Julio Cesar Fausto
Posted in PG::InsufficientPrivilege: ERROR: permission denied to create extension "pgcrypto" HINT: Must be superuser to create this extension. : CREATE EXTENSION IF NOT EXISTS "pgcrypto"
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
sudo su - postgres
ALTER ROLE deploy SUPERUSER;
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 :)