Skip to content

Commit 1dc932b

Browse files
committed
Add switch for move-tables to main.go
1 parent 8c45ee1 commit 1dc932b

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

go/base/context.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,11 @@ func (mctx *MigrationContext) CancelContext() {
10391039
}
10401040
}
10411041

1042+
// IsMoveTablesMode returns true if gh-ost should be used for moving tables instead of running a schema migration.
1043+
func (mctx *MigrationContext) IsMoveTablesMode() bool {
1044+
return len(mctx.MoveTables.TableNames) > 0
1045+
}
1046+
10421047
// SendWithContext attempts to send a value to a channel, but returns early
10431048
// if the context is cancelled. This prevents goroutine deadlocks when the
10441049
// channel receiver has exited due to an error.

go/cmd/gh-ost/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ func main() {
415415
var err error
416416
if migrationContext.Revert {
417417
err = migrator.Revert()
418+
} else if migrationContext.IsMoveTablesMode() {
419+
err = migrator.MoveTables()
418420
} else {
419421
err = migrator.Migrate()
420422
}

go/logic/migrator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,10 @@ func (mgtr *Migrator) Revert() error {
769769
return nil
770770
}
771771

772+
func (mgtr *Migrator) MoveTables() error {
773+
return nil
774+
}
775+
772776
// ExecOnFailureHook executes the onFailure hook, and this method is provided as the only external
773777
// hook access point
774778
func (mgtr *Migrator) ExecOnFailureHook() (err error) {

0 commit comments

Comments
 (0)