Skip to content

Commit

Permalink
catch setting role exception and output a warning instead of stop mig…
Browse files Browse the repository at this point in the history
…ration process
  • Loading branch information
runwuf committed Apr 1, 2022
1 parent 57427de commit 747330d
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions aiven_db_migrate/migrate/pgmigrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,17 +992,21 @@ def _migrate_roles(self) -> Dict[str, PGRoleTask]:
message=err.diag.message_primary,
)
else:
if role.rolconfig:
for conf in role.rolconfig:
key, value = conf.split("=", 1)
self.log.info("Setting config for role %r: %s = %s", role.rolname, key, value)
self.target.c(f'ALTER ROLE {role.safe_rolname} SET "{key}" = %s', args=(value, ), return_rows=0)
roles[role.rolname] = PGRoleTask(
rolname=rolname,
rolpassword=role.rolpassword,
status=PGRoleStatus.created,
message="role created",
)
try:
if role.rolconfig:
for conf in role.rolconfig:
key, value = conf.split("=", 1)
self.log.info("Setting config for role %r: %s = %s", role.rolname, key, value)
self.target.c(f'ALTER ROLE {role.safe_rolname} SET "{key}" = %s', args=(value, ), return_rows=0)
roles[role.rolname] = PGRoleTask(
rolname=rolname,
rolpassword=role.rolpassword,
status=PGRoleStatus.created,
message="role created",
)
except psycopg2.ProgrammingError as err:
self.log.warn(f'Setting config {role.rolname}: {key} = {value}. Error: {err}')


return roles

Expand Down

0 comments on commit 747330d

Please sign in to comment.