@@ -121,10 +121,33 @@ func (this *Inspector) inspectOriginalAndGhostTables() (err error) {
121121 if err != nil {
122122 return err
123123 }
124- if len (sharedUniqueKeys ) == 0 {
124+ for i , sharedUniqueKey := range sharedUniqueKeys {
125+ this .applyColumnTypes (this .migrationContext .DatabaseName , this .migrationContext .OriginalTableName , & sharedUniqueKey .Columns )
126+ uniqueKeyIsValid := true
127+ for _ , column := range sharedUniqueKey .Columns .Columns () {
128+ switch column .Type {
129+ case sql .FloatColumnType :
130+ {
131+ log .Warning ("Will not use %+v as shared key due to FLOAT data type" , sharedUniqueKey .Name )
132+ uniqueKeyIsValid = false
133+ }
134+ case sql .JSONColumnType :
135+ {
136+ // Noteworthy that at this time MySQL does not allow JSON indexing anyhow, but this code
137+ // will remain in place to potentially handle the future case where JSON is supported in indexes.
138+ log .Warning ("Will not use %+v as shared key due to JSON data type" , sharedUniqueKey .Name )
139+ uniqueKeyIsValid = false
140+ }
141+ }
142+ }
143+ if uniqueKeyIsValid {
144+ this .migrationContext .UniqueKey = sharedUniqueKeys [i ]
145+ break
146+ }
147+ }
148+ if this .migrationContext .UniqueKey == nil {
125149 return fmt .Errorf ("No shared unique key can be found after ALTER! Bailing out" )
126150 }
127- this .migrationContext .UniqueKey = sharedUniqueKeys [0 ]
128151 log .Infof ("Chosen shared unique key is %s" , this .migrationContext .UniqueKey .Name )
129152 if this .migrationContext .UniqueKey .HasNullable {
130153 if this .migrationContext .NullableUniqueKeyAllowed {
@@ -553,6 +576,11 @@ func (this *Inspector) applyColumnTypes(databaseName, tableName string, columnsL
553576 columnsList .GetColumn (columnName ).Type = sql .JSONColumnType
554577 }
555578 }
579+ if strings .Contains (columnType , "float" ) {
580+ for _ , columnsList := range columnsLists {
581+ columnsList .GetColumn (columnName ).Type = sql .FloatColumnType
582+ }
583+ }
556584 if strings .HasPrefix (columnType , "enum" ) {
557585 for _ , columnsList := range columnsLists {
558586 columnsList .GetColumn (columnName ).Type = sql .EnumColumnType
0 commit comments