postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

Provide option for change of owner of tables in Database which already exists

Open nv1-0 opened this issue 4 years ago • 3 comments

Currently when we apply Postgres CR it creates a DB if it doesn't exists and if it exists it changes its owner to the role created by the Postgres CRs. But the owner of the tables inside it remain unaltered due to which if we try to access it using credentials created by Postgres CRs then we get this error

<database>=> select * from <table>;
ERROR:  permission denied for table <table>

It would be great if we get an option to migrate the owners of all the tables in the database to the role created by Postgres CRs

nv1-0 avatar Jan 21 '21 13:01 nv1-0

I have created a pull request for this topic :- https://github.com/movetokube/postgres-operator/pull/58. Its missing tests right now. It can be reviewed

nv1-0 avatar Jan 22 '21 11:01 nv1-0

I think we already covered this in discussion on #58 - you can specify a masterRole that already owns the database and schemas and postgres-operator will not create a new owner role: https://github.com/movetokube/postgres-operator/blob/243a5ec8055010098209c63c1db0fb5535239618/pkg/controller/postgres/postgres_controller.go#L146-L149

It will then try to create this role and will just use the role provided in spec if it already exists:

https://github.com/movetokube/postgres-operator/blob/243a5ec8055010098209c63c1db0fb5535239618/pkg/postgres/role.go#L23-L28

hitman99 avatar Jul 07 '21 11:07 hitman99

I know this issue is more than half and a year old but it seems I have the same problem, even using masterRole with the existing role: new users access is denied on existing tables (I tried with OWNER privilege and it doesn't work better).

sambonbonne avatar Aug 24 '22 13:08 sambonbonne