Skip to content

Commit

Permalink
Fix unexpected alter table in auto migration
Browse files Browse the repository at this point in the history
  • Loading branch information
defool committed Dec 24, 2022
1 parent 794edad commit 9c5ca81
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions migrator/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy
}
}

if !isSameType {
if !isSameType && fullDataType != "mediumtext" && fullDataType != "longtext" {
// check size
if length, ok := columnType.Length(); length != int64(field.Size) {
if length > 0 && field.Size > 0 {
Expand Down Expand Up @@ -477,14 +477,6 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy
}
}

// check unique
if unique, ok := columnType.Unique(); ok && unique != field.Unique {
// not primary key
if !field.PrimaryKey {
alterColumn = true
}
}

// check default value
if !field.PrimaryKey {
currentDefaultNotNull := field.HasDefaultValue && !strings.EqualFold(field.DefaultValue, "NULL")
Expand Down

0 comments on commit 9c5ca81

Please sign in to comment.