diff --git a/go/base/context.go b/go/base/context.go index 5ab6d2a..f5a7bca 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -181,6 +181,7 @@ type MigrationContext struct { UniqueKey *sql.UniqueKey SharedColumns *sql.ColumnList ColumnRenameMap map[string]string + DroppedColumnsMap map[string]bool MappedSharedColumns *sql.ColumnList MigrationRangeMinValues *sql.ColumnValues MigrationRangeMaxValues *sql.ColumnValues diff --git a/go/logic/inspect.go b/go/logic/inspect.go index 1d30cb5..181ed0b 100644 --- a/go/logic/inspect.go +++ b/go/logic/inspect.go @@ -662,7 +662,14 @@ func (this *Inspector) getSharedColumns(originalColumns, ghostColumns *sql.Colum } sharedColumnNames := []string{} for _, originalColumn := range originalColumns.Names() { + isSharedColumn := false if columnsInGhost[originalColumn] || columnsInGhost[columnRenameMap[originalColumn]] { + isSharedColumn = true + } + if this.migrationContext.DroppedColumnsMap[originalColumn] { + isSharedColumn = false + } + if isSharedColumn { sharedColumnNames = append(sharedColumnNames, originalColumn) } } diff --git a/go/logic/migrator.go b/go/logic/migrator.go index 59432a3..092039e 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -248,6 +248,7 @@ func (this *Migrator) validateStatement() (err error) { } log.Infof("Alter statement has column(s) renamed. gh-ost finds the following renames: %v; --approve-renamed-columns is given and so migration proceeds.", this.parser.GetNonTrivialRenames()) } + this.migrationContext.DroppedColumnsMap = this.parser.DroppedColumnsMap() return nil } diff --git a/go/sql/parser.go b/go/sql/parser.go index 7875fcc..7114e10 100644 --- a/go/sql/parser.go +++ b/go/sql/parser.go @@ -111,3 +111,7 @@ func (this *Parser) GetNonTrivialRenames() map[string]string { func (this *Parser) HasNonTrivialRenames() bool { return len(this.GetNonTrivialRenames()) > 0 } + +func (this *Parser) DroppedColumnsMap() map[string]bool { + return this.droppedColumns +}