What I want to do is to login with differents users into the same PostgreSQL database. I need to get this done due to some circunstances that I am not going to describe here (too long).
First try
I have read this documentation page about PostgreSQL Roles. So I have created both users and inherit the permissions from one to the another
CREATE ROLE odoo WITH LOGIN CREATEDB REPLICATION PASSWORD 'odoo' NOINHERIT;
CREATE ROLE odoo_inherit WITH LOGIN CREATEDB REPLICATION PASSWORD 'odoo_inherit' INHERIT;
GRANT odoo TO odoo_inherit;
This is the result:
Role name | Attributes | Member of
-----------------+------------------------------------------+-----------
odoo | No inheritance, Create DB, Replication | {}
odoo_inherit | Create DB, Replication | {odoo}
Second try
I have tried faking the PostgreSQL role, but I cannot login neither from Odoo:
ALTER USER odoo_inherit SET ROLE odoo;
And in fact, when I create a table with the role odoo_inherit
the new owner of the new table is odoo
Results
The databases owned by the odoo
role are invisible for the odoo_inherit
user within Odoo. However I can log in the database with this psql
command
psql -U odoo_inherit -d dbname -W
Is there a way to achieve this? Is it a Odoo limitation? Am I missing anything?
Note: I have tried that because these are the answers of this other SO question