Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permission denied to create extension "pg_stat_statements" #230

Open
Startouf opened this issue Mar 9, 2022 · 3 comments
Open

permission denied to create extension "pg_stat_statements" #230

Startouf opened this issue Mar 9, 2022 · 3 comments

Comments

@Startouf
Copy link

Startouf commented Mar 9, 2022

Describe the bug

Trying to setup a new chatwoot server, and running either db:chatwoot_prepare or db:schema:load

rails aborted!
ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR:  permission denied to create extension "pg_stat_statements"
HINT:  Must be superuser to create this extension.
/home/chatwoot/chatwoot/db/schema.rb:16:in `block in <main>'
/home/chatwoot/chatwoot/db/schema.rb:13:in `<main>'

Caused by:
PG::InsufficientPrivilege: ERROR:  permission denied to create extension "pg_stat_statements"
HINT:  Must be superuser to create this extension.

To Reproduce

My PG Setup

CREATE USER chatwoot NOINHERIT LOGIN PASSWORD '<password>';
CREATE DATABASE chatwoot_production OWNER chatwoot;
GRANT ALL PRIVILEGES ON DATABASE chatwoot_production to chatwoot;

Expected behavior

A clear indication on what roles to give to chatwoot in the readme. Also, expecting chatwoot to get superadmin privilegies seems a bit excessive. Is there no other way to configure what you need ?

Screenshots

N/A

Browser logs

N/A

Server logs

N/A

Environment

Self hosted chatwoot, Linux VM deployment
release/2.2.1

Desktop (please complete the following information):

  • OS: Debian 13

Smartphone (please complete the following information):
N/A

Additional context

Add any other context about the problem here.

@Startouf
Copy link
Author

Startouf commented Mar 9, 2022

How to fix :

# postgresql.conf
shared_preload_libraries = 'pg_stat_statements'

Restart your DB server
login to psql and create the extension (not sure if it had to be done on the admin db or the chatwoot db or both)

CREATE EXTENSION pg_stat_statements; 
\c chatwoot_production
CREATE EXTENSION pg_stat_statements;

This should be added somewhere in the doc

@sojan-official
Copy link
Member

@Startouf Thanks for reporting this. We will take a look and have it added to the documentation.

@sojan-official sojan-official transferred this issue from chatwoot/chatwoot Mar 10, 2022
@shivshav
Copy link

Had to do something similar for our setup. We actually needed pgcrypto too

CREATE EXTENSION pg_stat_statements; 
CREATE EXTENSION pgcrypto; 

As a sidenote: As part of the documentation, it'd be nice for administrators to know what these extensions are used for in the application if possible 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants