File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed
lib/charms/postgresql_k8s/v0 Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change 36
36
37
37
# Increment this PATCH version before using `charmcraft publish-lib` or reset
38
38
# to 0 if you are raising the major API version
39
- LIBPATCH = 36
39
+ LIBPATCH = 37
40
40
41
41
INVALID_EXTRA_USER_ROLE_BLOCKING_MESSAGE = "invalid role(s) for extra user roles"
42
42
@@ -393,24 +393,32 @@ def _generate_database_privileges_statements(
393
393
SET lomowner = (SELECT oid FROM pg_roles WHERE rolname = '{}')
394
394
WHERE lomowner = (SELECT oid FROM pg_roles WHERE rolname = '{}');""" .format (user , self .user )
395
395
)
396
+ for schema in schemas :
397
+ statements .append (
398
+ sql .SQL ("ALTER SCHEMA {} OWNER TO {};" ).format (
399
+ sql .Identifier (schema ), sql .Identifier (user )
400
+ )
401
+ )
396
402
else :
397
403
for schema in schemas :
398
404
schema = sql .Identifier (schema )
399
- statements .append (
405
+ statements .extend ([
400
406
sql .SQL ("GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA {} TO {};" ).format (
401
407
schema , sql .Identifier (user )
402
- )
403
- )
404
- statements .append (
408
+ ),
405
409
sql .SQL ("GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA {} TO {};" ).format (
406
410
schema , sql .Identifier (user )
407
- )
408
- )
409
- statements .append (
411
+ ),
410
412
sql .SQL ("GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA {} TO {};" ).format (
411
413
schema , sql .Identifier (user )
412
- )
413
- )
414
+ ),
415
+ sql .SQL ("GRANT USAGE ON SCHEMA {} TO {};" ).format (
416
+ schema , sql .Identifier (user )
417
+ ),
418
+ sql .SQL ("GRANT CREATE ON SCHEMA {} TO {};" ).format (
419
+ schema , sql .Identifier (user )
420
+ ),
421
+ ])
414
422
return statements
415
423
416
424
def get_last_archived_wal (self ) -> str :
You can’t perform that action at this time.
0 commit comments