Skip to content

Commit

Permalink
fix(backend): sqlserver 以集群为维度处理rename_infos #8461
Browse files Browse the repository at this point in the history
  • Loading branch information
ygcyao authored and iSecloud committed Dec 9, 2024
1 parent 2b3c254 commit 18e8281
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions dbm-ui/backend/ticket/builders/sqlserver/sqlserver_data_migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ def __init__(self, rename_type, ticket: Ticket):

def format_db_rename_infos(self, cluster_key, from_key, to_key):
"""填充db重命名信息"""
dbrename_infos: List[Dict[str, str]] = []
dbrename_infos_dict = defaultdict(list)
for info in self.ticket_data["infos"]:
dbrename_infos.extend(
[
{
"cluster_id": info[cluster_key],
"rename_infos": [{"db_name": db[from_key], "target_db_name": db[to_key]}],
}
for db in info["rename_infos"]
if db.get(from_key) and db.get(to_key)
]
)
cluster_id = info[cluster_key]
for db in info["rename_infos"]:
if db.get(from_key) and db.get(to_key):
dbrename_infos_dict[cluster_id].append({"db_name": db[from_key], "target_db_name": db[to_key]})

# 以集群为维度 将字典转换为所需的列表格式
dbrename_infos = [
{"cluster_id": cluster_id, "rename_infos": rename_infos}
for cluster_id, rename_infos in dbrename_infos_dict.items()
]
return dbrename_infos

def format_target_cluster_rename_infos(self):
Expand Down

0 comments on commit 18e8281

Please sign in to comment.