From 980fd9c6fe69a47a6d2ea37c4197fdbb6974042f Mon Sep 17 00:00:00 2001 From: ycggyao Date: Wed, 28 Aug 2024 19:29:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(sqlserver):=20sqlserver=20dts=5Fmode?= =?UTF-8?q?=E3=80=81=E6=89=B9=E9=87=8F=E6=9F=A5=E8=AF=A2=E5=8D=95=E6=8D=AE?= =?UTF-8?q?=E3=80=81=E6=96=B0=E6=9C=BA=E9=87=8D=E5=BB=BA=E5=8D=95=E6=8D=AE?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=B7=BB=E5=8A=A0clusters=20#6516=20#=20Revi?= =?UTF-8?q?ewed,=20transaction=20id:=2016757?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builders/sqlserver/sqlserver_data_migrate.py | 10 +++++++++- .../builders/sqlserver/sqlserver_restore_slave.py | 2 +- dbm-ui/backend/ticket/views.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_data_migrate.py b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_data_migrate.py index 0c34cef706..8fbb4c5cb8 100644 --- a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_data_migrate.py +++ b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_data_migrate.py @@ -48,15 +48,23 @@ def validate(self, attrs): rename_infos = serializers.ListSerializer(help_text=_("迁移DB信息"), child=RenameInfoSerializer()) dts_id = serializers.IntegerField(help_text=_("迁移记录ID"), required=False) - dts_mode = serializers.ChoiceField(help_text=_("迁移方式"), choices=SqlserverDtsMode.get_choices()) need_auto_rename = serializers.BooleanField(help_text=_("迁移后,系统是否对源DB进行重命名")) manual_terminate = serializers.BooleanField(help_text=_("手动终止迁移"), required=False, default=False) infos = serializers.ListSerializer(help_text=_("迁移信息列表"), child=DataMigrateInfoSerializer()) def validate(self, attrs): """验证库表数据库的数据""" + # TODO: 根据单据类型固定迁移方式 # TODO: 验证target_db_name如果在目标集群存在,则rename_db_name不为空 # TODO: 验证所有的rename_db_name一定不在目标集群存在 + ticket_type = self.context["ticket_type"] + if ticket_type == TicketType.SQLSERVER_FULL_MIGRATE: + attrs["dts_mode"] = SqlserverDtsMode.FULL + elif ticket_type == TicketType.SQLSERVER_INCR_MIGRATE: + attrs["dts_mode"] = SqlserverDtsMode.INCR + else: + raise ValueError("Unknown ticket type") + super().validate(attrs) # 校验集群是否可用 super().validate_cluster_can_access(attrs) diff --git a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_slave.py b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_slave.py index 66161f1c5b..5fc53a845b 100644 --- a/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_slave.py +++ b/dbm-ui/backend/ticket/builders/sqlserver/sqlserver_restore_slave.py @@ -133,4 +133,4 @@ def patch_ticket_detail(self): info["system_version"] = db_config["system_version"].split(",") # 添加集群信息 - self.patch_cluster_details() + super().patch_ticket_detail() diff --git a/dbm-ui/backend/ticket/views.py b/dbm-ui/backend/ticket/views.py index 43e1c11a70..a127002e44 100644 --- a/dbm-ui/backend/ticket/views.py +++ b/dbm-ui/backend/ticket/views.py @@ -85,7 +85,7 @@ class TicketViewSet(viewsets.AuditedModelViewSet): queryset = Ticket.objects.all() serializer_class = TicketSerializer filter_fields = { - "id": ["exact"], + "id": ["exact", "in"], "bk_biz_id": ["exact"], "ticket_type": ["exact", "in"], "status": ["exact", "in"],