@@ -173,8 +173,7 @@ func (this *Inspector) inspectOriginalAndGhostTables() (err error) {
173
173
// This additional step looks at which columns are unsigned. We could have merged this within
174
174
// the `getTableColumns()` function, but it's a later patch and introduces some complexity; I feel
175
175
// comfortable in doing this as a separate step.
176
- this .applyColumnTypes (this .migrationContext .DatabaseName , this .migrationContext .OriginalTableName , this .migrationContext .OriginalTableColumns , this .migrationContext .SharedColumns )
177
- this .applyColumnTypes (this .migrationContext .DatabaseName , this .migrationContext .OriginalTableName , & this .migrationContext .UniqueKey .Columns )
176
+ this .applyColumnTypes (this .migrationContext .DatabaseName , this .migrationContext .OriginalTableName , this .migrationContext .OriginalTableColumns , this .migrationContext .SharedColumns , & this .migrationContext .UniqueKey .Columns )
178
177
this .applyColumnTypes (this .migrationContext .DatabaseName , this .migrationContext .GetGhostTableName (), this .migrationContext .GhostTableColumns , this .migrationContext .MappedSharedColumns )
179
178
180
179
for i := range this .migrationContext .SharedColumns .Columns () {
@@ -552,44 +551,35 @@ func (this *Inspector) applyColumnTypes(databaseName, tableName string, columnsL
552
551
err := sqlutils .QueryRowsMap (this .db , query , func (m sqlutils.RowMap ) error {
553
552
columnName := m .GetString ("COLUMN_NAME" )
554
553
columnType := m .GetString ("COLUMN_TYPE" )
555
- if strings .Contains (columnType , "unsigned" ) {
556
- for _ , columnsList := range columnsLists {
557
- columnsList .SetUnsigned (columnName )
554
+ for _ , columnsList := range columnsLists {
555
+ column := columnsList .GetColumn (columnName )
556
+ if column == nil {
557
+ continue
558
558
}
559
- }
560
- if strings .Contains (columnType , "mediumint" ) {
561
- for _ , columnsList := range columnsLists {
562
- columnsList .GetColumn (columnName ).Type = sql .MediumIntColumnType
559
+
560
+ if strings .Contains (columnType , "unsigned" ) {
561
+ column .IsUnsigned = true
563
562
}
564
- }
565
- if strings .Contains (columnType , "timestamp" ) {
566
- for _ , columnsList := range columnsLists {
567
- columnsList .GetColumn (columnName ).Type = sql .TimestampColumnType
563
+ if strings .Contains (columnType , "mediumint" ) {
564
+ column .Type = sql .MediumIntColumnType
568
565
}
569
- }
570
- if strings .Contains (columnType , "datetime" ) {
571
- for _ , columnsList := range columnsLists {
572
- columnsList .GetColumn (columnName ).Type = sql .DateTimeColumnType
566
+ if strings .Contains (columnType , "timestamp" ) {
567
+ column .Type = sql .TimestampColumnType
573
568
}
574
- }
575
- if strings .Contains (columnType , "json" ) {
576
- for _ , columnsList := range columnsLists {
577
- columnsList .GetColumn (columnName ).Type = sql .JSONColumnType
569
+ if strings .Contains (columnType , "datetime" ) {
570
+ column .Type = sql .DateTimeColumnType
578
571
}
579
- }
580
- if strings .Contains (columnType , "float" ) {
581
- for _ , columnsList := range columnsLists {
582
- columnsList .GetColumn (columnName ).Type = sql .FloatColumnType
572
+ if strings .Contains (columnType , "json" ) {
573
+ column .Type = sql .JSONColumnType
583
574
}
584
- }
585
- if strings .HasPrefix (columnType , "enum" ) {
586
- for _ , columnsList := range columnsLists {
587
- columnsList .GetColumn (columnName ).Type = sql .EnumColumnType
575
+ if strings .Contains (columnType , "float" ) {
576
+ column .Type = sql .FloatColumnType
588
577
}
589
- }
590
- if charset := m .GetString ("CHARACTER_SET_NAME" ); charset != "" {
591
- for _ , columnsList := range columnsLists {
592
- columnsList .SetCharset (columnName , charset )
578
+ if strings .HasPrefix (columnType , "enum" ) {
579
+ column .Type = sql .EnumColumnType
580
+ }
581
+ if charset := m .GetString ("CHARACTER_SET_NAME" ); charset != "" {
582
+ column .Charset = charset
593
583
}
594
584
}
595
585
return nil
0 commit comments