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

Create schemas for users in granted databases

Open benjaminjb opened this issue 1 year ago • 0 comments

Checklist:

  • [ ] Have you added an explanation of what your changes do and why you'd like them to be included?
  • [ ] Have you updated or added documentation for the change, as applicable?
  • [ ] Have you tested your changes on all related environments with successful results, as applicable?
    • [ ] Have you added automated tests?

Type of Changes:

  • [x] New feature
  • [ ] Bug fix
  • [ ] Documentation
  • [ ] Testing enhancement
  • [ ] Other

What is the current behavior (link to any open issues here)?

What is the new behavior (if this is a feature change)?

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

To help developers set up and connect quickly, the operator can now create schemas for spec.users without using an init SQL script.

This is a gated feature: to turn on set the FeatureGate AutoCreateUserSchema=true.

If turned on, a cluster can be annotated with postgres-operator.crunchydata.com/autoCreateUserSchema=true.

If the feature is turned on and the cluster is annotated, PGO will create a schema named after the user in every database where that user has permissions.

(PG note: creating a schema with the same name as the user means that the PG search_path should not need to be updated, since search_path defaults to "$user", public.)

As with our usual pattern, the operator does not remove/delete PG objects (users, databases) that are removed from the spec.

NOTE: There are several schema names that would be dangerous to the cluster's operation; for instance, if you had pgbouncer enabled (which would create a pgbouncer schema) it would be dangerous to create a user named pgbouncer and use this feature to create a schema for that user.

Other Information:

Issues: [PGO-1333] Fixes https://github.com/CrunchyData/postgres-operator/issues/3568

benjaminjb avatar Jun 21 '24 19:06 benjaminjb