perf: check type
This commit is contained in:
parent
311b852cfd
commit
ca4fcb94c0
@ -411,14 +411,20 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy
|
|||||||
if !field.PrimaryKey {
|
if !field.PrimaryKey {
|
||||||
// check type
|
// check type
|
||||||
var isSameType bool
|
var isSameType bool
|
||||||
|
if strings.HasPrefix(fullDataType, realDataType) {
|
||||||
|
isSameType = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// check type aliases
|
||||||
|
if !isSameType {
|
||||||
aliases := m.DB.Migrator().GetTypeAliases(realDataType)
|
aliases := m.DB.Migrator().GetTypeAliases(realDataType)
|
||||||
aliases = append(aliases, realDataType)
|
|
||||||
for _, alias := range aliases {
|
for _, alias := range aliases {
|
||||||
if strings.HasPrefix(fullDataType, alias) {
|
if strings.HasPrefix(fullDataType, alias) {
|
||||||
isSameType = true
|
isSameType = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !isSameType {
|
if !isSameType {
|
||||||
alterColumn = true
|
alterColumn = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user