diff --git a/dm/config/task_converters.go b/dm/config/task_converters.go index a05ca5856f8..cb8a1c83484 100644 --- a/dm/config/task_converters.go +++ b/dm/config/task_converters.go @@ -610,21 +610,14 @@ 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.TaskTableMigrateRuleSource{ Schema: schemaPattern, SourceName: sourceName, Table: tablePattern, }, } if targetSchema != "" { - tableMigrateRule.Target = &struct { - Schema *string `json:"schema,omitempty"` - Table *string `json:"table,omitempty"` - }{ + 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 44562c47697..70398998685 100644 --- a/dm/config/task_converters_test.go +++ b/dm/config/task_converters_test.go @@ -459,18 +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 = struct { - Schema string `json:"schema"` - SourceName string `json:"source_name"` - Table string `json:"table"` - }{ + task.TableMigrateRule[0].Source = openapi.TaskTableMigrateRuleSource{ SourceName: source1Name, Schema: sourceSchema, } - task.TableMigrateRule[0].Target = &struct { - Schema *string `json:"schema,omitempty"` - Table *string `json:"table,omitempty"` - }{ + task.TableMigrateRule[0].Target = &openapi.TaskTableMigrateRuleTarget{ Schema: &targetSchema, } taskCfg, err = OpenAPITaskToTaskConfig(&task, sourceCfgMap) @@ -504,38 +497,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.TaskTableMigrateRuleSource{ 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.TaskTableMigrateRuleTarget{ 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.TaskTableMigrateRuleSource{ 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.TaskTableMigrateRuleTarget{ Schema: &targetSchema, Table: &targetTable, } @@ -578,11 +557,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.TaskTableMigrateRuleSource{ SourceName: source1Name, Schema: sourceSchema, Table: "", diff --git a/dm/openapi/gen.server.go b/dm/openapi/gen.server.go index 1b1b4d48027..a9608ce1d33 100644 --- a/dm/openapi/gen.server.go +++ b/dm/openapi/gen.server.go @@ -1320,43 +1320,43 @@ var swaggerSpec = []string{ "eNNIcFYrzA7icLZ/dDDZfxE+n8zn6PkEHj07mByFs8WLw+jZy/hgdjyfPJ8dzg/3D8azZ4fPD6OD0Br+", "4uDZ/mR/dhAt9g+PouggOp5P5s9nzvZX9Rplq52VelAVi/vezGidQIdOvbadc+WOk17f5tcyBh5QJgwl", "UDp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R/", - "1KTASre0hvzKtIHSH8SgDFzjEIFrxDjcKhM1UNodNrpUBVKKysR0BTffLqExgM0PwrSIujeA84q7Y8NM", - "anE77BHqWXdctZeX8+6l4y+rm33bkHVzp+v7qXcfAE9Un9d2dhPhmpquM93K/UwNeqR9b95R3ZwN9rcE", - "z+7oZ9MK6+5s8U31Pd2khq/BHRtFx3brVUdYXMIyMCj29Wzd6bo5/83qpgIfbCx3Z5tmP5xib9vrri33", - "FshVd6x/bvrOlKYN3feW/r6b1n6qHNFVbK1gQNeIAByrT6IAni+KsI+VTYt+llv7Iv0BZmJn+OIRcqXf", - "Qzs1gshDX4u8jqJq/+73lVQ/ZQbYahX1/RKMsx89wVhWVw9MMFomy3M+VzTjKxptDkkH1Rp48p1RZI9e", - "HOE8Y9HN9U1T95Gv6OHX4TPq/vvdE6oxvz7+mXibW3buZFyd1dnVFZBEpi2t+YHRXJi7aLh2sfjuUjm4", - "lqysInu9lrR+RaK7naD/IEL5s7qti7/dJW735uINS97KYrefLP2zCG9nZclZiffAoiTfWyRow5TEIkEX", - "guWhyNlPmXpqMjX2d7T1kbzggME0d38AcPfT9zXJ4xaLb5qc+SkhPyVk/n2CpTrz7X6w1CmG/ixZmZ75", - "KYobL/6jCOLDpyitpGBTDv9ctdha4jY0m91eq4C9dS4XcswPmPku8d71+7hqk++YfB52s8j6Ou0OKvuy", - "pfmu19bv6CUmc61Cc89m3EmzXuVFsx9Sd2m0d1910cyvudTHR9h1saP15vNrmu9FNIWYqNbzI0lqM4Fb", - "F4z6ut1HNBzc4t70tJ9+zXF4NVEaeKLLUidVV7Cajhm5PDOF9nahusFiNYlSCx61bBuaogtsOa744fbz", - "7f8FAAD//wuB/EzIvQAA", + "1f5mrnCOxqOPMOe1mrOKD50JC39FuM6MCGqfu9t5Ej4wkdvwBtVDNUHByA7dIR8PKygZ1nbLhbrV5aG0", + "JZvOUdz2H96ZqwOS+wmZnbz1JPbH4AYnUQhZVGSs61nZxeTXex4jt4qCfMfLoqpnb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p83+KA5pOKHIsZX", + "MRr37b/9BY5tOduOj3xs7nDPHwyeMify5O2c7iILIImKwl0ICLqxd9214W0dMP1mnRr0W7kT9bBkik6d", + "sEzoQvWWywn+mtdbpPgNXv0QY5DB815RbyuMmOrLzjQrIIEJN33ciiY9KqFj6j5cqkPNcU+dsQOGV/MB", + "gH08NR5iQ3aRVx7Hpm3TnnTos/Ig9tDJi4byVIBYfTmsbV+6GKIvjbMzPPF5O3bPlca/rSdCJbi334c1", + "npgeMlkseF/bNo30t7JUEtzv9pgvau0Wi/bFDE/OtmgiP8CmVl2aOvZUf2Dq55Zuc0tLN/S+O6pCss2E", + "9VPRrPXHNCeujwDeGnuyq5qh6pYZ50T3Wy5u+j4Mg22gOH5w9nJ8nm9Xucsoqa0zV9kHroO3qkbjPy5r", + "tZutD3eDnzanKQ6o9YjenJesT+IPCLF1R90hydotsI6/H912A9x6F+EdOaAqWu7polRfcnYoe0y/6T+q", + "DN4AZlEVuE+PV8Ydhbue5SvcBy7vrOvdKpfW28DsFpPquua782jZYmuIBit7UD4da9h5w+dRzoIa3xzc", + "EfZRX9OodacvGm7f18MSDBIe6yLtDvfq0gz70XON7XLWP4uLVTBCqaoogPrjQLpWoIe79BFPn2YqPrna", + "y0CS5yG/eszTb3Ova7EuOnnqnoeuNYtnQw1W2WOya1WHfDSXbfY2HW+UnrZs5pZVbevLug4mVEROTM/V", + "p6NoS6gqdtfV9EOO9y91c7jtHe7b1wW+59G+67ORO3TOX340sb7DTXU2DSm5Rqyo3O3afj1wm/tfgNLD", + "AjjWPIw5wCTLhf7QgNGl+qMrBVa65TbkV6ZNlf5gB2XgGocIXCPG4VaZqIHS7rDRpSqQUlQmpmu5+bYK", + "jQFsfrCmRdS9AZxX3B0bZlKL22GPUM+646q9vJx3Lx1/Wd3s24asmztd30+9+wB4ovq8trObCNfUdMXp", + "Vu5natAj7XvzjurmbLC/JXh2Rz+bVl13Z4tvqi/rJjV8De7YKDq2W8M6wuISloFBsa+n7E7XzflvVjcV", + "+GBjuTvbNPvhFHvbXndtubdArrpj/XPTd6Y0bei+t/T33bT2U+WIrmJrBQO6RgTgWH2yBfB8UYR9rGyq", + "9LPc2hfpDzATO8MXj5Ar/R7aqRFEHvpa+HUUVft3v6+k+ikzwFarqO+XYJz96AnGsrp6YILRMlme87mi", + "WWDRCHRIOqjWYJTvjCJ79OII5xmLbv5vms6PfEUPvw6fUX8foHtCNebXxz8Tb3PLzp2Mq7M6u7oCksi0", + "zTU/MJoLcxcN1y4W310qB9eSlVVkr9eS1q9IdLcT9B9EKH9Wt3Xxt7vE7d5cvGHJW1ns9pOlfxbh7aws", + "OSvxHliU5HuLBG2Yklgk6EKwPBQ5+ylTT02mxv5OtT6SFxwwmObuDxTufvq+JnncYvFNkzM/JeSnhMy/", + "T7BUZ77dD5Y6xdCfJSvTMz9FcePFfxRBfPgUpZUUbMrhn6sWW0vchmaz22sVsLfO5UKO+QEz3yXeu34f", + "V23yHZPPw24WWV/P3UFlX7Y03/Xa+h29xGSuVWju2Yw7adarvGj2Q+oujfbuqy6a+TWX+vgIuy52tN58", + "fk3zvYimEBPVen4kSW0mcOuCUV+3+4iGg1vcm5720685Dq8mSgNPdFnqpOoKVtMxI5dnptDeLlQ3WKwm", + "UWrBo5ZtQ1N0gS3HFT/cfr79vwAAAP//GKowv2i+AAA=", } // 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 3af0810e682..4e747dfdf0d 100644 --- a/dm/openapi/gen.types.go +++ b/dm/openapi/gen.types.go @@ -703,25 +703,31 @@ type TaskTableMigrateRule struct { BinlogFilterRule *[]string `json:"binlog_filter_rule,omitempty"` // source-related configuration - Source struct { - // schema name, wildcard support - Schema string `json:"schema"` + Source TaskTableMigrateRuleSource `json:"source"` - // source name - SourceName string `json:"source_name"` + // downstream-related configuration + Target *TaskTableMigrateRuleTarget `json:"target,omitempty"` +} - // table name, wildcard support - Table string `json:"table"` - } `json:"source"` +// source-related configuration +type TaskTableMigrateRuleSource struct { + // schema name, wildcard support + Schema string `json:"schema"` - // downstream-related configuration - Target *struct { - // schema name, does not support wildcards - Schema *string `json:"schema,omitempty"` + // 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"` - } `json:"target,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 b6de1b9c9db..69a082ea2cb 100644 --- a/dm/openapi/spec/dm.yaml +++ b/dm/openapi/spec/dm.yaml @@ -1412,6 +1412,37 @@ components: - "user" - "enable_gtid" - "enable" + TaskTableMigrateRuleSource: + 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" + TaskTableMigrateRuleTarget: + 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: @@ -1646,37 +1677,9 @@ 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/TaskTableMigrateRuleSource" 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/TaskTableMigrateRuleTarget" binlog_filter_rule: type: array description: "filter rule name"