Skip to content

Commit 747330d

Browse files
committed
catch setting role exception and output a warning instead of stop migration process
1 parent 57427de commit 747330d

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

aiven_db_migrate/migrate/pgmigrate.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -992,17 +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-
)
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+
except psycopg2.ProgrammingError as err:
1008+
self.log.warn(f'Setting config {role.rolname}: {key} = {value}. Error: {err}')
1009+
10061010

10071011
return roles
10081012

0 commit comments

Comments
 (0)