From db748cccec70e24dee344ede782c1c953abd99b0 Mon Sep 17 00:00:00 2001 From: Jiaqiang Huang <96465211+River2000i@users.noreply.github.com> Date: Wed, 25 Dec 2024 12:16:41 +0800 Subject: [PATCH 1/4] refactor TableMigrateRule --- dm/config/task_converters.go | 5 +- dm/config/task_converters_test.go | 39 ++-------- dm/openapi/gen.server.go | 114 +++++++++++++++--------------- dm/openapi/gen.types.go | 40 ++++++----- dm/openapi/spec/dm.yaml | 61 ++++++++-------- 5 files changed, 121 insertions(+), 138 deletions(-) diff --git a/dm/config/task_converters.go b/dm/config/task_converters.go index 98a9373e066..35ec1a9ff17 100644 --- a/dm/config/task_converters.go +++ b/dm/config/task_converters.go @@ -586,10 +586,7 @@ func SubTaskConfigsToOpenAPITask(subTaskConfigList []*SubTaskConfig) *openapi.Ta }, } if targetSchema != "" { - tableMigrateRule.Target = &struct { - Schema *string `json:"schema,omitempty"` - Table *string `json:"table,omitempty"` - }{ + tableMigrateRule.Target = &openapi.TableMigrateRuleTarget{ Schema: &targetSchema, } if targetTable != "" { diff --git a/dm/config/task_converters_test.go b/dm/config/task_converters_test.go index fc368db2384..278bc087f86 100644 --- a/dm/config/task_converters_test.go +++ b/dm/config/task_converters_test.go @@ -433,18 +433,11 @@ func TestConvertBetweenOpenAPITaskAndTaskConfig(t *testing.T) { sourceSchema := task.TableMigrateRule[0].Source.Schema targetSchema := *task.TableMigrateRule[0].Target.Schema // only route schema - task.TableMigrateRule[0].Source = struct { - Schema string `json:"schema"` - SourceName string `json:"source_name"` - Table string `json:"table"` - }{ + task.TableMigrateRule[0].Source = openapi.TableMigrateRuleSource{ SourceName: source1Name, Schema: sourceSchema, } - task.TableMigrateRule[0].Target = &struct { - Schema *string `json:"schema,omitempty"` - Table *string `json:"table,omitempty"` - }{ + task.TableMigrateRule[0].Target = &openapi.TableMigrateRuleTarget{ Schema: &targetSchema, } taskCfg, err = OpenAPITaskToTaskConfig(&task, sourceCfgMap) @@ -478,38 +471,24 @@ func TestConvertBetweenOpenAPITaskAndTaskConfig(t *testing.T) { // only route table will meet error sourceTable := "tb" targetTable := "tb1" - task.TableMigrateRule[0].Source = struct { - Schema string `json:"schema"` - SourceName string `json:"source_name"` - Table string `json:"table"` - }{ + task.TableMigrateRule[0].Source = openapi.TableMigrateRuleSource{ SourceName: source1Name, Schema: sourceSchema, Table: sourceTable, } - task.TableMigrateRule[0].Target = &struct { - Schema *string `json:"schema,omitempty"` - Table *string `json:"table,omitempty"` - }{ + task.TableMigrateRule[0].Target = &openapi.TableMigrateRuleTarget{ Table: &targetTable, } _, err = OpenAPITaskToTaskConfig(&task, sourceCfgMap) require.True(t, terror.ErrConfigGenTableRouter.Equal(err)) // route both - task.TableMigrateRule[0].Source = struct { - Schema string `json:"schema"` - SourceName string `json:"source_name"` - Table string `json:"table"` - }{ + task.TableMigrateRule[0].Source = openapi.TableMigrateRuleSource{ SourceName: source1Name, Schema: sourceSchema, Table: sourceTable, } - task.TableMigrateRule[0].Target = &struct { - Schema *string `json:"schema,omitempty"` - Table *string `json:"table,omitempty"` - }{ + task.TableMigrateRule[0].Target = &openapi.TableMigrateRuleTarget{ Schema: &targetSchema, Table: &targetTable, } @@ -552,11 +531,7 @@ func TestConvertBetweenOpenAPITaskAndTaskConfig(t *testing.T) { require.EqualValues(t, taskAfterConvert, &task) // no route and sync one schema - task.TableMigrateRule[0].Source = struct { - Schema string `json:"schema"` - SourceName string `json:"source_name"` - Table string `json:"table"` - }{ + task.TableMigrateRule[0].Source = openapi.TableMigrateRuleSource{ SourceName: source1Name, Schema: sourceSchema, Table: "", diff --git a/dm/openapi/gen.server.go b/dm/openapi/gen.server.go index 8e3c3258821..1f105f3af1b 100644 --- a/dm/openapi/gen.server.go +++ b/dm/openapi/gen.server.go @@ -1300,63 +1300,63 @@ var swaggerSpec = []string{ "1ygKlIdOw6vAc6DeqWaLiytO0rhPiv26syClwdOpSitydOT4JNaeCgad/9DzOpBdSEpgspRUcS1hn7rd", "rHC4KhNimIPi5Y3ieCVvm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6l373hGrMr49/Jt7mlp07GVdndXZ1BSSRaUtrfmA0F+YuGq5dLL67VA6uJSur", - "yF6vJa1fkehuJ+g/iFD+rG7r4m93idu9uXjDkrey2O0nS/8swttZWXJW4j2wKMn3FgnaMCWxSNCFYHko", - "cvZTpp6aTI39HW19JC84YDDN3R/z2/30fU3yuMXimyZnfkrITwmZf59gqc58ux8sdYqhP0tWpmd+iuLG", - "i/8ogvjwKUorKdiUwz9XLbaWuA3NZrfXKmBvncuFHPMDZr5LvHf9Pq7a5Dsmn4fdLLK+NLuDyr5sab7r", - "tfU7eonJXKvQ3LMZd9KsV3nR7IfUXRrt3VddNPNrLvXxEXZd7Gi9+fya5nsRTSEmqvX8SJLaTODWBaO+", - "bvcRDQe3uDc97adfcxxeTZQGnuiy1EnVFaymY0Yuz0yhvV2obrBYTaLUgkct24am6AJbjit+uP18+38B", - "AAD//3gHYjaUvQAA", + "yPr2ODejKXguOln5AluKfWzVEg+3qLmUjCrbMEWKn/IEdWcgJtI3FijqOWbWG9GZMR2DG5xEIWQR4HnW", + "DF5H0WLy6z1tVysS8dk0USVR6pZmkaAhsAonrJ1etCFQsfZnx0ZcljmrRjq4dHcfcjMiirg+ONUIlhjz", + "xrbM70jBgQuIxXyYZ6fIdd/cvK9Esm25Lk0lVdsZ8ZndGCdSPbBcUwZGEZZvweRjbXSfH/Uak3O6/E1N", + "Jtli5CIGIitIQhTo2/RBURy7gmSJemunrBBL5wTKLYqpvjlvLulHUQKyJF9iMuQSPV4SylCgijakrivJ", + "37ior4aBjCFT3qGGOXfrGjGuGbx3u1QRos34xaltlE5U4Dn2SlUVW0r0uaCsqGbyHoBWk3prEv3uuc2N", + "/MqdLqEkiHKVHhCO2Vb0Rm7eCpJIn1XECQ6lXlDF1pI78lQXIGSJPtopLhJp4lt2wVK00oaqcNl9fHgD", + "1+pgklJpaqFA0k20FssQ56Z+azQeVcVc7sW0chyWZlTRhXrByjXeJc3XV9su4QtFUMEeNIkyMHNRiJWa", + "r1XY1s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+ "bKZF1L0BnFfcHRtmUovbYY9Qz7rjqr28nHcvHX9Z3ezbhqybO13fT737AHii+ry2s5sI19R0E+lW7mdq", + "0CPte/OO6uZssL8leHZHP5t2RXdni2+qN+UmNXwN7tgoOrbbYzrC4hKWgUGxr6/mTtfN+W9WNxX4YGO5", + "O9s0++EUe9ted225t0CuumP9c9N3pjRt6L639PfdtPZT5YiuYmsFA7pGBOBYfW4F8HxRhH2sbEbzs9za", + "F+kPMBM7wxePkCv9HtqpEUQe+lqfdRRV+3e/r6T6KTPAVquo75dgnP3oCcayunpggtEyWZ7zuaLJWtFA", + "cUg6qNaYke+MInv04gjnGYtugG4ab498RQ+/Dp9R90jvnlCN+fXxz8Tb3LJzJ+PqrM6uroAkMu1GzQ+M", + "5sLcRcO1i8V3l8rBtWRlFdnrtaT1KxLd7QT9BxHKn9VtXfztLnG7NxdvWPJWFrv9ZOmfRXg7K0vOSrwH", + "FiX53iJBG6YkFgm6ECwPRc5+ytRTk6mx/6NvPpIXHDCY5u6PtO1++r4medxi8U2TMz8l5KeEzL9PsFRn", + "vt0PljrF0J8lK9MzP0Vx48V/FEF8+BSllRRsyuGfqxZbS9yGZrPbaxWwt87lQo75ATPfJd67fh9XbfId", + "k8/DbhZZXxDdQWVftjTf9dr6Hb3EZK5VaO7ZjDtp1qu8aPZD6i6N9u6rLpr5NZf6+Ai7Lna03nx+TfO9", + "iKYQE9V6fiRJbSZw64JRX7f7iIaDW9ybnvbTrzkOryZKA090Weqk6gpW0zEjl2em0N4uVDdYrCZRasGj", + "lm1DU3SBLccVP9x+vv2/AAAA//9t1ebiJL4AAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/dm/openapi/gen.types.go b/dm/openapi/gen.types.go index 647c25bf2ef..72f397cf5cd 100644 --- a/dm/openapi/gen.types.go +++ b/dm/openapi/gen.types.go @@ -524,6 +524,27 @@ type SyncStatus struct { UnresolvedGroups []ShardingGroup `json:"unresolved_groups"` } +// source-related configuration +type TableMigrateRuleSource struct { + // schema name, wildcard support + Schema string `json:"schema"` + + // source name + SourceName string `json:"source_name"` + + // table name, wildcard support + Table string `json:"table"` +} + +// downstream-related configuration +type TableMigrateRuleTarget struct { + // schema name, does not support wildcards + Schema *string `json:"schema,omitempty"` + + // table name, does not support wildcards + Table *string `json:"table,omitempty"` +} + // schema name list type TableNameList []string @@ -700,25 +721,10 @@ type TaskTableMigrateRule struct { BinlogFilterRule *[]string `json:"binlog_filter_rule,omitempty"` // source-related configuration - Source struct { - // schema name, wildcard support - Schema string `json:"schema"` - - // source name - SourceName string `json:"source_name"` - - // table name, wildcard support - Table string `json:"table"` - } `json:"source"` + Source TableMigrateRuleSource `json:"source"` // downstream-related configuration - Target *struct { - // schema name, does not support wildcards - Schema *string `json:"schema,omitempty"` - - // table name, does not support wildcards - Table *string `json:"table,omitempty"` - } `json:"target,omitempty"` + Target *TableMigrateRuleTarget `json:"target,omitempty"` } // downstream database configuration diff --git a/dm/openapi/spec/dm.yaml b/dm/openapi/spec/dm.yaml index 2fea9d8da86..c9a79498bf7 100644 --- a/dm/openapi/spec/dm.yaml +++ b/dm/openapi/spec/dm.yaml @@ -1412,6 +1412,37 @@ components: - "user" - "enable_gtid" - "enable" + TableMigrateRuleSource: + description: source-related configuration + properties: + source_name: + type: string + description: source name + example: "source-name" + schema: + type: string + description: schema name, wildcard support + example: "db-*" + table: + type: string + description: table name, wildcard support + example: "tb-*" + required: + - "source_name" + - "schema" + - "table" + TableMigrateRuleTarget: + type: object + description: downstream-related configuration + properties: + schema: + type: string + description: schema name, does not support wildcards + example: "db1" + table: + type: string + description: table name, does not support wildcards + example: "tb1" ShardingGroup: type: object properties: @@ -1645,37 +1676,11 @@ components: description: "upstream table to downstream migrate rules" properties: source: - type: object description: source-related configuration - properties: - source_name: - type: string - description: source name - example: "source-name" - schema: - type: string - description: schema name, wildcard support - example: "db-*" - table: - type: string - description: table name, wildcard support - example: "tb-*" - required: - - "source_name" - - "schema" - - "table" + $ref: "#/components/schemas/TableMigrateRuleSource" target: - type: object description: downstream-related configuration - properties: - schema: - type: string - description: schema name, does not support wildcards - example: "db1" - table: - type: string - description: table name, does not support wildcards - example: "tb1" + $ref: "#/components/schemas/TableMigrateRuleTarget" binlog_filter_rule: type: array description: "filter rule name" From f98cc754ead96df1ee95367a76b79c0f5f45f920 Mon Sep 17 00:00:00 2001 From: Jiaqiang Huang <96465211+River2000i@users.noreply.github.com> Date: Wed, 25 Dec 2024 12:20:37 +0800 Subject: [PATCH 2/4] refactor source --- dm/config/task_converters.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dm/config/task_converters.go b/dm/config/task_converters.go index 35ec1a9ff17..e901069aa50 100644 --- a/dm/config/task_converters.go +++ b/dm/config/task_converters.go @@ -575,11 +575,7 @@ func SubTaskConfigsToOpenAPITask(subTaskConfigList []*SubTaskConfig) *openapi.Ta ruleMap := map[string]struct{}{} appendOneRule := func(sourceName, schemaPattern, tablePattern, targetSchema, targetTable string) { tableMigrateRule := openapi.TaskTableMigrateRule{ - Source: struct { - Schema string `json:"schema"` - SourceName string `json:"source_name"` - Table string `json:"table"` - }{ + Source: openapi.TableMigrateRuleSource{ Schema: schemaPattern, SourceName: sourceName, Table: tablePattern, From 86e945ffc0bf7b6cc276a0f10fd00ebd061e5112 Mon Sep 17 00:00:00 2001 From: Jiaqiang Huang <96465211+River2000i@users.noreply.github.com> Date: Thu, 2 Jan 2025 13:25:09 +0800 Subject: [PATCH 3/4] fmt --- dm/openapi/gen.server.go | 114 +++++++++++++++++++-------------------- dm/openapi/gen.types.go | 46 ++++++++-------- dm/openapi/spec/dm.yaml | 10 ++-- 3 files changed, 84 insertions(+), 86 deletions(-) diff --git a/dm/openapi/gen.server.go b/dm/openapi/gen.server.go index 1f105f3af1b..027e5e35709 100644 --- a/dm/openapi/gen.server.go +++ b/dm/openapi/gen.server.go @@ -1300,63 +1300,63 @@ var swaggerSpec = []string{ "1ygKlIdOw6vAc6DeqWaLiytO0rhPiv26syClwdOpSitydOT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jcwq5R/913erdftB912wjyFOVHM4ftVODHeUEDpv0Zdmr799", - "ZHHGV03qwqGlLPIwRJx7wN2sIL0917hNDRdQ+k73g3a0HK6G9OKP3Jyy0aKtq+anw5/011K2N7pa0Xt5", - "19zS5aDwYQQ19Z28qxNmX8XSHWo/+6o9G32SH76Dh7fT71ZbeNyqtJeQyjg5oaEjL3nyDnzIEHn18Qyc", - "fHgjVS5LRsejvia1E2k8J9pVwZSYnrXagYypYnEsFOKtBYrTz+PRkSSgysxkiMAMj45HB+onqfHFSkE7", - "hRmeXs+npnHRtJjeOBRlT8GzSK316uNZvS+fKn7RmlXNtz+bqVtf1Y0lmJUJnum/uK7orELKzqbi7g6A", - "iuoNs6gVmdpEnqcpZOvRscQBlB0ASUwBz8MVgBzU2gIKuORWyz5VY5HlPuy18mkSQInhaxqtHwz3doPB", - "FtJmWbCQ694+4X3IFc1qW7HnJPztuMWPunCJD2XJqp3i4zCmo31jF1nGo8MHBKPVEtSxtDbnHYJhdZAv", - "DNcmGzP9pv9QRVO3Wv8lSPuBjp36EMcJJkiT7b0+SM0ggynSu/zP1jmvBV4Ra6m+R1CsRoUhGFkwjGw1", - "rk/IXQks/4caPrcY59Dhhz+xHaWaro3vAQzayMJhGChhVa/Px5EwR2/RHZMw6zsGG0mY2ZjpN+OFbSRh", - "xnscIGE2eH4Js2D4sSWs/lWKzo2M0r0COKdkvUXihIb/dfHhvUeU6mDJucoL6212i2gI1HIVVBENGxAZ", - "H7UDnL9dvjsfBI4c2APOSujaDx84OsjrVz1Vh94+ZpbyVVxcVi0wyruAiqe/5oitLabGYhWUIxxM7K6w", - "uh07vk60BgyJnOmeZLqQa2LaERV36lwg1LrwbALD5+1qX0dTZIek2J0ikqJ1eYMPmkMqfihifBWjcd/+", - "21/P2Jaz7fhAx+YO9/zB4ClzIk/ezukOsACSqChehICgG3vXXRve1gHTb1bxfb+VO1EPS6bo1AnLhC5U", - "X7ic4K95vb2J3+DV7wIMMnje6+VthRFTfVGZZgUkMO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", + "tWwbmqILbDmu+OH28+3/BQAA//+AYWh/NL4AAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/dm/openapi/gen.types.go b/dm/openapi/gen.types.go index 72f397cf5cd..0dc665d7ff8 100644 --- a/dm/openapi/gen.types.go +++ b/dm/openapi/gen.types.go @@ -524,27 +524,6 @@ type SyncStatus struct { UnresolvedGroups []ShardingGroup `json:"unresolved_groups"` } -// source-related configuration -type TableMigrateRuleSource struct { - // schema name, wildcard support - Schema string `json:"schema"` - - // source name - SourceName string `json:"source_name"` - - // table name, wildcard support - Table string `json:"table"` -} - -// downstream-related configuration -type TableMigrateRuleTarget struct { - // schema name, does not support wildcards - Schema *string `json:"schema,omitempty"` - - // table name, does not support wildcards - Table *string `json:"table,omitempty"` -} - // schema name list type TableNameList []string @@ -721,10 +700,31 @@ type TaskTableMigrateRule struct { BinlogFilterRule *[]string `json:"binlog_filter_rule,omitempty"` // source-related configuration - Source TableMigrateRuleSource `json:"source"` + Source TaskTableMigrateRuleSource `json:"source"` // downstream-related configuration - Target *TableMigrateRuleTarget `json:"target,omitempty"` + Target *TaskTableMigrateRuleTarget `json:"target,omitempty"` +} + +// source-related configuration +type TaskTableMigrateRuleSource struct { + // schema name, wildcard support + Schema string `json:"schema"` + + // source name + SourceName string `json:"source_name"` + + // table name, wildcard support + Table string `json:"table"` +} + +// downstream-related configuration +type TaskTableMigrateRuleTarget struct { + // schema name, does not support wildcards + Schema *string `json:"schema,omitempty"` + + // table name, does not support wildcards + Table *string `json:"table,omitempty"` } // downstream database configuration diff --git a/dm/openapi/spec/dm.yaml b/dm/openapi/spec/dm.yaml index c9a79498bf7..2a83506dc6d 100644 --- a/dm/openapi/spec/dm.yaml +++ b/dm/openapi/spec/dm.yaml @@ -1412,7 +1412,7 @@ components: - "user" - "enable_gtid" - "enable" - TableMigrateRuleSource: + TaskTableMigrateRuleSource: description: source-related configuration properties: source_name: @@ -1431,7 +1431,7 @@ components: - "source_name" - "schema" - "table" - TableMigrateRuleTarget: + TaskTableMigrateRuleTarget: type: object description: downstream-related configuration properties: @@ -1676,11 +1676,9 @@ components: description: "upstream table to downstream migrate rules" properties: source: - description: source-related configuration - $ref: "#/components/schemas/TableMigrateRuleSource" + $ref: "#/components/schemas/TaskTableMigrateRuleSource" target: - description: downstream-related configuration - $ref: "#/components/schemas/TableMigrateRuleTarget" + $ref: "#/components/schemas/TaskTableMigrateRuleTarget" binlog_filter_rule: type: array description: "filter rule name" From 06988bfcaf12a9e81f5083d3b122e0bf26fd39b7 Mon Sep 17 00:00:00 2001 From: Jiaqiang Huang <96465211+River2000i@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:17:06 +0800 Subject: [PATCH 4/4] fix test --- dm/config/task_converters.go | 4 ++-- dm/config/task_converters_test.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dm/config/task_converters.go b/dm/config/task_converters.go index 7d206cda0d8..cb8a1c83484 100644 --- a/dm/config/task_converters.go +++ b/dm/config/task_converters.go @@ -610,14 +610,14 @@ func SubTaskConfigsToOpenAPITask(subTaskConfigList []*SubTaskConfig) *openapi.Ta ruleMap := map[string]struct{}{} appendOneRule := func(sourceName, schemaPattern, tablePattern, targetSchema, targetTable string) { tableMigrateRule := openapi.TaskTableMigrateRule{ - Source: openapi.TableMigrateRuleSource{ + Source: openapi.TaskTableMigrateRuleSource{ Schema: schemaPattern, SourceName: sourceName, Table: tablePattern, }, } if targetSchema != "" { - tableMigrateRule.Target = &openapi.TableMigrateRuleTarget{ + tableMigrateRule.Target = &openapi.TaskTableMigrateRuleTarget{ Schema: &targetSchema, } if targetTable != "" { diff --git a/dm/config/task_converters_test.go b/dm/config/task_converters_test.go index 5f916cb7ea9..70398998685 100644 --- a/dm/config/task_converters_test.go +++ b/dm/config/task_converters_test.go @@ -459,11 +459,11 @@ func TestConvertBetweenOpenAPITaskAndTaskConfig(t *testing.T) { sourceSchema := task.TableMigrateRule[0].Source.Schema targetSchema := *task.TableMigrateRule[0].Target.Schema // only route schema - task.TableMigrateRule[0].Source = openapi.TableMigrateRuleSource{ + task.TableMigrateRule[0].Source = openapi.TaskTableMigrateRuleSource{ SourceName: source1Name, Schema: sourceSchema, } - task.TableMigrateRule[0].Target = &openapi.TableMigrateRuleTarget{ + task.TableMigrateRule[0].Target = &openapi.TaskTableMigrateRuleTarget{ Schema: &targetSchema, } taskCfg, err = OpenAPITaskToTaskConfig(&task, sourceCfgMap) @@ -497,24 +497,24 @@ func TestConvertBetweenOpenAPITaskAndTaskConfig(t *testing.T) { // only route table will meet error sourceTable := "tb" targetTable := "tb1" - task.TableMigrateRule[0].Source = openapi.TableMigrateRuleSource{ + task.TableMigrateRule[0].Source = openapi.TaskTableMigrateRuleSource{ SourceName: source1Name, Schema: sourceSchema, Table: sourceTable, } - task.TableMigrateRule[0].Target = &openapi.TableMigrateRuleTarget{ + task.TableMigrateRule[0].Target = &openapi.TaskTableMigrateRuleTarget{ Table: &targetTable, } _, err = OpenAPITaskToTaskConfig(&task, sourceCfgMap) require.True(t, terror.ErrConfigGenTableRouter.Equal(err)) // route both - task.TableMigrateRule[0].Source = openapi.TableMigrateRuleSource{ + task.TableMigrateRule[0].Source = openapi.TaskTableMigrateRuleSource{ SourceName: source1Name, Schema: sourceSchema, Table: sourceTable, } - task.TableMigrateRule[0].Target = &openapi.TableMigrateRuleTarget{ + task.TableMigrateRule[0].Target = &openapi.TaskTableMigrateRuleTarget{ Schema: &targetSchema, Table: &targetTable, } @@ -557,7 +557,7 @@ func TestConvertBetweenOpenAPITaskAndTaskConfig(t *testing.T) { require.EqualValues(t, taskAfterConvert, &task) // no route and sync one schema - task.TableMigrateRule[0].Source = openapi.TableMigrateRuleSource{ + task.TableMigrateRule[0].Source = openapi.TaskTableMigrateRuleSource{ SourceName: source1Name, Schema: sourceSchema, Table: "",