diff --git a/sync.go b/sync.go index adc2d859..9e1cb8c1 100644 --- a/sync.go +++ b/sync.go @@ -235,6 +235,15 @@ func (session *Session) SyncWithOptions(opts SyncOptions, beans ...interface{}) } } + if oriIndex != nil && oriIndex.Type != index.Type { + sql := engine.dialect.DropIndexSQL(tbNameWithSchema, oriIndex) + _, err = session.exec(sql) + if err != nil { + return nil, err + } + oriIndex = nil + } + if oriIndex == nil { addedNames[name] = index }