You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: go/cmd/gh-ost/main.go
+37-1Lines changed: 37 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ import (
12
12
"os"
13
13
"os/signal"
14
14
"regexp"
15
+
"strings"
15
16
"syscall"
16
17
17
18
"github.com/github/gh-ost/go/base"
@@ -164,8 +165,16 @@ func main() {
164
165
version:=flag.Bool("version", false, "Print version & exit")
165
166
checkFlag:=flag.Bool("check-flag", false, "Check if another flag exists/supported. This allows for cross-version scripting. Exits with 0 when all additional provided flags exist, nonzero otherwise. You must provide (dummy) values for flags that require a value. Example: gh-ost --check-flag --cut-over-lock-timeout-seconds --nice-ratio 0")
166
167
flag.StringVar(&migrationContext.ForceTmpTableName, "force-table-names", "", "table name prefix to be used on the temporary tables")
167
-
flag.CommandLine.SetOutput(os.Stdout)
168
168
169
+
// move tables flags
170
+
moveTables:=flag.String("move-tables", "", "Comma delimited list of tables to move. e.g. 'table1,table2,table3'. This is a special mode that allows you to move tables between database clusters. This mode is mutually exclusive with --alter, --table, --test-on-replica, --migrate-on-replica, --execute-on-replica, and --revert.")
171
+
flag.StringVar(&migrationContext.MoveTables.TargetHost, "target-host", "", "Target MySQL hostname for --move-tables mode. Must be specified if --move-tables is specified.")
172
+
flag.IntVar(&migrationContext.MoveTables.TargetPort, "target-port", 3306, "Target MySQL port for --move-tables mode. Defaults to 3306.")
173
+
flag.StringVar(&migrationContext.MoveTables.TargetUser, "target-user", "", "Target MySQL username for --move-tables mode. If not provided, uses the same user as the source connection")
174
+
flag.StringVar(&migrationContext.MoveTables.TargetPass, "target-password", "", "Target MySQL password for --move-tables mode. If not provided, uses the same password as the source connection")
175
+
flag.StringVar(&migrationContext.MoveTables.TargetDatabase, "target-database", "", "Target MySQL database name for --move-tables mode. If not provided, uses the same database name as the source connection")
176
+
177
+
flag.CommandLine.SetOutput(os.Stdout)
169
178
flag.Parse()
170
179
171
180
if*checkFlag {
@@ -320,6 +329,33 @@ func main() {
320
329
migrationContext.Log.Warning("--exact-rowcount with --panic-on-warnings: row counts cannot be exact due to warning detection")
321
330
}
322
331
332
+
if*moveTables!="" {
333
+
ifmigrationContext.AlterStatement!="" {
334
+
log.Fatal("--move-tables is mutually exclusive with --alter")
335
+
}
336
+
ifmigrationContext.OriginalTableName!="" {
337
+
log.Fatal("--move-tables is mutually exclusive with --table")
338
+
}
339
+
ifmigrationContext.TestOnReplica {
340
+
log.Fatal("--move-tables is mutually exclusive with --test-on-replica")
341
+
}
342
+
ifmigrationContext.MigrateOnReplica {
343
+
log.Fatal("--move-tables is mutually exclusive with --migrate-on-replica")
344
+
}
345
+
ifmigrationContext.Revert {
346
+
log.Fatal("--move-tables is mutually exclusive with --revert")
347
+
}
348
+
ifmigrationContext.MoveTables.TargetHost=="" {
349
+
log.Fatal("--target-host must be specified when using --move-tables")
0 commit comments