Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

migrate: Clarify variable names in rename_indexes_constraints.

Anders Kaseorg0a43d0b8243a
diff --git a/zerver/lib/migrate.py b/zerver/lib/migrate.py
index cb5c37e6f8d..e45c328522f 100644
--- a/zerver/lib/migrate.py
+++ b/zerver/lib/migrate.py
@@ -69,24 +69,26 @@ def rename_indexes_constraints(
with connection.cursor() as cursor:
constraints = connection.introspection.get_constraints(cursor, old_table)
- for old_name, infodict in constraints.items():
- if infodict["check"]:
+ for old_name, constraint in constraints.items():
+ if constraint["check"]:
suffix = "_check"
is_index = False
- elif infodict["foreign_key"] is not None:
+ elif constraint["foreign_key"] is not None:
is_index = False
- to_table, to_column = infodict["foreign_key"]
+ to_table, to_column = constraint["foreign_key"]
suffix = f"_fk_{to_table}_{to_column}"
- elif infodict["primary_key"]:
+ elif constraint["primary_key"]:
suffix = "_pk"
is_index = True
- elif infodict["unique"]:
+ elif constraint["unique"]:
suffix = "_uniq"
is_index = True
else:
- suffix = "_idx" if len(infodict["columns"]) > 1 else ""
+ suffix = "_idx" if len(constraint["columns"]) > 1 else ""
is_index = True
- new_name = schema_editor._create_index_name(new_table, infodict["columns"], suffix)
+ new_name = schema_editor._create_index_name(
+ new_table, constraint["columns"], suffix
+ )
if new_name in seen_indexes:
# This index duplicates one we already renamed,
# and attempting to rename it would cause a
@@ -117,9 +119,9 @@ def rename_indexes_constraints(
)
cursor.execute(raw_query)
- for infodict in connection.introspection.get_sequences(cursor, old_table):
- old_name = infodict["name"]
- column = infodict["column"]
+ for sequence in connection.introspection.get_sequences(cursor, old_table):
+ old_name = sequence["name"]
+ column = sequence["column"]
new_name = f"{new_table}_{column}_seq"
raw_query = SQL("ALTER SEQUENCE {old_name} RENAME TO {new_name}").format(