Port changes from https://github.com/canonical/postgresql-k8s-operator/pull/1015 into `16/edge` (or `16/stable` if available)