postgres-operator
postgres-operator copied to clipboard
Provide option for change of owner of tables in Database which already exists
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
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
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
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).