Skip to content

Commit 8738524

Browse files
get rid of GetTargetTableName
1 parent 69e1110 commit 8738524

4 files changed

Lines changed: 6 additions & 17 deletions

File tree

go/base/context.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -571,17 +571,6 @@ func (mctx *MigrationContext) GetGhostTableName() string {
571571
}
572572
}
573573

574-
// GetTargetTableName generates the name of the target table. In move-tables mode
575-
// each table keeps its own name on the target, so there is no single target
576-
// table name; per-table code uses MoveTable.TargetTableName instead, and calling
577-
// this is a programmer error that panics to fail fast.
578-
func (mctx *MigrationContext) GetTargetTableName() string {
579-
if mctx.IsMoveTablesMode() {
580-
panic("GetTargetTableName() must not be called in move-tables mode; use MoveTable.TargetTableName")
581-
}
582-
return mctx.GetGhostTableName()
583-
}
584-
585574
// GetTargetDatabaseName fetches the name of the target database, which defaults to the original
586575
// database name unless we're in move-tables mode.
587576
func (mctx *MigrationContext) GetTargetDatabaseName() string {

go/logic/applier.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func (apl *Applier) compileMigrationKeyWarningRegex() (*regexp.Regexp, error) {
164164
if apl.migrationContext.IsMoveTablesMode() {
165165
return apl.compileMoveTablesKeyWarningRegex()
166166
}
167-
return compileKeyWarningRegex(apl.migrationContext.GetTargetTableName(), apl.migrationContext.UniqueKey.NameInGhostTable)
167+
return compileKeyWarningRegex(apl.migrationContext.GetGhostTableName(), apl.migrationContext.UniqueKey.NameInGhostTable)
168168
}
169169

170170
// compileMoveTablesKeyWarningRegex builds one duplicate-key warning regex
@@ -422,7 +422,7 @@ func (apl *Applier) prepareQueries() (err error) {
422422
targetDatabaseName := apl.migrationContext.GetTargetDatabaseName()
423423

424424
if !apl.migrationContext.IsMoveTablesMode() {
425-
targetTableName := apl.migrationContext.GetTargetTableName()
425+
targetTableName := apl.migrationContext.GetGhostTableName()
426426
if apl.dmlDeleteQueryBuilder, err = sql.NewDMLDeleteQueryBuilder(
427427
targetDatabaseName,
428428
targetTableName,

go/logic/hooks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func (he *HooksExecutor) applyEnvironmentVariables(extraVariables ...string) []s
288288
if he.migrationContext.IsMoveTablesMode() {
289289
targetTableNameEnv = strings.Join(he.migrationContext.MoveTables.TableNames, ",")
290290
} else {
291-
targetTableNameEnv = he.migrationContext.GetTargetTableName()
291+
targetTableNameEnv = he.migrationContext.GetGhostTableName()
292292
}
293293
env = append(env, fmt.Sprintf("GH_OST_TARGET_TABLE_NAME=%s", targetTableNameEnv))
294294
env = append(env, extraVariables...)

go/logic/migrator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,11 +2078,11 @@ func (mgtr *Migrator) printMigrationStatusHint(writers ...io.Writer) {
20782078
mgtr.migrationContext.StartTime.Format(time.RubyDate),
20792079
)
20802080
} else {
2081-
fmt.Fprintf(w, "# Migrating %s.%s; Target table is %s.%s\n",
2081+
fmt.Fprintf(w, "# Migrating %s.%s; Ghost table is %s.%s\n",
20822082
sql.EscapeName(mgtr.migrationContext.DatabaseName),
20832083
sql.EscapeName(mgtr.migrationContext.OriginalTableName),
2084-
sql.EscapeName(mgtr.migrationContext.GetTargetDatabaseName()),
2085-
sql.EscapeName(mgtr.migrationContext.GetTargetTableName()),
2084+
sql.EscapeName(mgtr.migrationContext.DatabaseName),
2085+
sql.EscapeName(mgtr.migrationContext.GetGhostTableName()),
20862086
)
20872087
fmt.Fprintf(w, "# Migrating %+v; inspecting %+v; executing on %+v\n",
20882088
*mgtr.applier.connectionConfig.ImpliedKey,

0 commit comments

Comments
 (0)