@@ -992,18 +992,21 @@ def _migrate_roles(self) -> Dict[str, PGRoleTask]:
992992 message = err .diag .message_primary ,
993993 )
994994 else :
995- if role .rolconfig :
996- for conf in role .rolconfig :
997- key , value = conf .split ("=" , 1 )
998- self .log .info ("Setting config for role %r: %s = %s" , role .rolname , key , value )
999- self .target .c (f'ALTER ROLE { role .safe_rolname } SET "{ key } " = %s' , args = (value , ), return_rows = 0 )
1000- roles [role .rolname ] = PGRoleTask (
1001- rolname = rolname ,
1002- rolpassword = role .rolpassword ,
1003- status = PGRoleStatus .created ,
1004- message = "role created" ,
1005- )
1006-
995+ try :
996+ if role .rolconfig :
997+ for conf in role .rolconfig :
998+ key , value = conf .split ("=" , 1 )
999+ self .log .info ("Setting config for role %r: %s = %s" , role .rolname , key , value )
1000+ self .target .c (f'ALTER ROLE { role .safe_rolname } SET "{ key } " = %s' , args = (value , ), return_rows = 0 )
1001+ roles [role .rolname ] = PGRoleTask (
1002+ rolname = rolname ,
1003+ rolpassword = role .rolpassword ,
1004+ status = PGRoleStatus .created ,
1005+ message = "role created" ,
1006+ )
1007+ # display warning when ProgrammingErrorERROR 42501: InsufficientPrivilege: permission denied to set parameter for a role
1008+ except psycopg2 .errors .InsufficientPrivilege :
1009+ self .log .warning (f'Setting config [{ role .rolname } ]: [{ key } ] = [{ value } ] failed. psycopg2.errors.InsufficientPrivilege' )
10071010 return roles
10081011
10091012 @staticmethod
0 commit comments