dialect/sql/schema: fix bug in atlas integration when working WithDropIndex/WithDropColumn (#2374)

* dialect/sql/schema: fix no change condition in atlas

* dialect/sql/schema: fix bug in atlas integration when working WithDropIndex/WithDropColumn

Co-authored-by: Zeev Manilovich <zeevmanilovich@gmail.com>
This commit is contained in:
Ariel Mashraki
2022-03-03 21:52:44 +02:00
committed by GitHub
parent 8753baae78
commit 35a098fdbb
2 changed files with 9 additions and 7 deletions

View File

@@ -14,6 +14,7 @@ import (
"ariga.io/atlas/sql/migrate"
"ariga.io/atlas/sql/schema"
"entgo.io/ent/dialect"
entsql "entgo.io/ent/dialect/sql"
"entgo.io/ent/schema/field"
@@ -272,18 +273,18 @@ func (m *Migrate) setupAtlas() error {
if m.withFixture {
return errors.New("sql/schema: WithFixture(true) does not work in Atlas migration")
}
k := DropIndex | DropColumn
skip := DropIndex | DropColumn
if m.atlas.skip != NoChange {
k = m.atlas.skip
skip = m.atlas.skip
}
if m.dropIndexes {
k |= ^DropIndex
skip &= ^DropIndex
}
if m.dropColumns {
k |= ^DropColumn
skip &= ^DropColumn
}
if k == NoChange {
m.atlas.diff = append(m.atlas.diff, filterChanges(k))
if skip != NoChange {
m.atlas.diff = append(m.atlas.diff, filterChanges(skip))
}
if m.atlas.dir != nil && m.atlas.fmt == nil {
m.atlas.fmt = migrate.DefaultFormatter