diff --git a/go/cmd/vtctldclient/command/vreplication/common/cancel.go b/go/cmd/vtctldclient/command/vreplication/common/cancel.go index 5db27746eb5..48abcc89584 100644 --- a/go/cmd/vtctldclient/command/vreplication/common/cancel.go +++ b/go/cmd/vtctldclient/command/vreplication/common/cancel.go @@ -27,7 +27,7 @@ import ( vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" ) -var cancelOptions = struct { +var CancelOptions = struct { KeepData bool KeepRoutingRules bool }{} @@ -56,8 +56,8 @@ func commandCancel(cmd *cobra.Command, args []string) error { req := &vtctldatapb.WorkflowDeleteRequest{ Keyspace: BaseOptions.TargetKeyspace, Workflow: BaseOptions.Workflow, - KeepData: cancelOptions.KeepData, - KeepRoutingRules: cancelOptions.KeepRoutingRules, + KeepData: CancelOptions.KeepData, + KeepRoutingRules: CancelOptions.KeepRoutingRules, } resp, err := GetClient().WorkflowDelete(GetCommandCtx(), req) if err != nil { diff --git a/go/cmd/vtctldclient/command/vreplication/movetables/create.go b/go/cmd/vtctldclient/command/vreplication/movetables/create.go index 673460e1910..e7109f390d4 100644 --- a/go/cmd/vtctldclient/command/vreplication/movetables/create.go +++ b/go/cmd/vtctldclient/command/vreplication/movetables/create.go @@ -120,17 +120,3 @@ func commandMoveTablesCreate(cmd *cobra.Command, args []string) error { } return nil } - -func registerCreateCommand(root *cobra.Command) { - common.AddCommonCreateFlags(moveTablesCreate) - moveTablesCreate.PersistentFlags().StringVar(&moveTablesCreateOptions.SourceKeyspace, "source-keyspace", "", "Keyspace where the tables are being moved from.") - moveTablesCreate.MarkPersistentFlagRequired("source-keyspace") - moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.SourceShards, "source-shards", nil, "Source shards to copy data from when performing a partial moveTables (experimental).") - moveTablesCreate.Flags().StringVar(&moveTablesCreateOptions.SourceTimeZone, "source-time-zone", "", "Specifying this causes any DATETIME fields to be converted from the given time zone into UTC.") - moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.AllTables, "all-tables", false, "Copy all tables from the source.") - moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.IncludeTables, "tables", nil, "Source tables to copy.") - moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.ExcludeTables, "exclude-tables", nil, "Source tables to exclude from copying.") - moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.NoRoutingRules, "no-routing-rules", false, "(Advanced) Do not create routing rules while creating the workflow. See the reference documentation for limitations if you use this flag.") - moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.AtomicCopy, "atomic-copy", false, "(EXPERIMENTAL) A single copy phase is run for all tables from the source. Use this, for example, if your source keyspace has tables which use foreign key constraints.") - moveTables.AddCommand(moveTablesCreate) -} diff --git a/go/cmd/vtctldclient/command/vreplication/movetables/movetables.go b/go/cmd/vtctldclient/command/vreplication/movetables/movetables.go index f00bee8498a..5158f324531 100644 --- a/go/cmd/vtctldclient/command/vreplication/movetables/movetables.go +++ b/go/cmd/vtctldclient/command/vreplication/movetables/movetables.go @@ -37,7 +37,18 @@ func registerMoveTablesCommands(root *cobra.Command) { common.AddCommonFlags(moveTables) root.AddCommand(moveTables) - registerCreateCommand(moveTables) + common.AddCommonCreateFlags(moveTablesCreate) + moveTablesCreate.PersistentFlags().StringVar(&moveTablesCreateOptions.SourceKeyspace, "source-keyspace", "", "Keyspace where the tables are being moved from.") + moveTablesCreate.MarkPersistentFlagRequired("source-keyspace") + moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.SourceShards, "source-shards", nil, "Source shards to copy data from when performing a partial moveTables (experimental).") + moveTablesCreate.Flags().StringVar(&moveTablesCreateOptions.SourceTimeZone, "source-time-zone", "", "Specifying this causes any DATETIME fields to be converted from the given time zone into UTC.") + moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.AllTables, "all-tables", false, "Copy all tables from the source.") + moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.IncludeTables, "tables", nil, "Source tables to copy.") + moveTablesCreate.Flags().StringSliceVar(&moveTablesCreateOptions.ExcludeTables, "exclude-tables", nil, "Source tables to exclude from copying.") + moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.NoRoutingRules, "no-routing-rules", false, "(Advanced) Do not create routing rules while creating the workflow. See the reference documentation for limitations if you use this flag.") + moveTablesCreate.Flags().BoolVar(&moveTablesCreateOptions.AtomicCopy, "atomic-copy", false, "(EXPERIMENTAL) A single copy phase is run for all tables from the source. Use this, for example, if your source keyspace has tables which use foreign key constraints.") + moveTables.AddCommand(moveTablesCreate) + opts := &common.SubCommandsOpts{ SubCommand: "MoveTables", Workflow: "commerce2customer", @@ -56,8 +67,17 @@ func registerMoveTablesCommands(root *cobra.Command) { common.AddCommonSwitchTrafficFlags(reverseTrafficCommand, false) moveTables.AddCommand(reverseTrafficCommand) - moveTables.AddCommand(common.GetCompleteCommand(opts)) - moveTables.AddCommand(common.GetCancelCommand(opts)) + complete := common.GetCompleteCommand(opts) + complete.Flags().BoolVar(&common.CompleteOptions.KeepData, "keep-data", false, "Keep the original source table data that was copied by the MoveTables workflow") + complete.Flags().BoolVar(&common.CompleteOptions.KeepRoutingRules, "keep-routing-rules", false, "Keep the routing rules in place that direct table traffic from the source keyspace to the target keyspace of the MoveTables workflow") + complete.Flags().BoolVar(&common.CompleteOptions.RenameTables, "rename-tables", false, "Keep the original source table data that was copied by the MoveTables workflow, but rename each table to '__old'") + complete.Flags().BoolVar(&common.CompleteOptions.DryRun, "dry-run", false, "Print the actions that would be taken and report any known errors that would have occurred") + moveTables.AddCommand(complete) + + cancel := common.GetCancelCommand(opts) + cancel.Flags().BoolVar(&common.CancelOptions.KeepData, "keep-data", false, "Keep the partially copied table data from the MoveTables workflow in the target keyspace") + cancel.Flags().BoolVar(&common.CancelOptions.KeepRoutingRules, "keep-routing-rules", false, "Keep the routing rules created for the MoveTables workflow") + moveTables.AddCommand(cancel) } func init() {