dialect/sql/schema: fix postgres index migration (#1351)

Fix PostgreSQL index migration when table_name = type_name.
Closed #1344
This commit is contained in:
Ariel Mashraki
2021-03-18 22:29:39 +02:00
committed by GitHub
parent 14ed353ca9
commit b4ad29f7f3
6 changed files with 50 additions and 26 deletions

View File

@@ -390,9 +390,7 @@ func (m *Migrate) changeSet(curr, new *Table) (*changes, error) {
// Drop indexes.
for _, idx := range curr.Indexes {
_, ok1 := new.fk(idx.Name)
_, ok2 := new.index(idx.Name)
if !ok1 && !ok2 {
if _, isFK := new.fk(idx.Name); !isFK && !new.hasIndex(idx.Name, idx.realname) {
change.index.drop.append(idx)
}
}