Skip to content

Commit

Permalink
AutoMigrate() should always migrate checks, even there is no relation…
Browse files Browse the repository at this point in the history
…ship constranits.
  • Loading branch information
googollee committed Aug 25, 2022
1 parent 1400547 commit 205d638
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions migrator/migrator.go
Expand Up @@ -135,12 +135,12 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
}
}
}
}

for _, chk := range stmt.Schema.ParseCheckConstraints() {
if !tx.Migrator().HasConstraint(value, chk.Name) {
if err := tx.Migrator().CreateConstraint(value, chk.Name); err != nil {
return err
}
for _, chk := range stmt.Schema.ParseCheckConstraints() {
if !tx.Migrator().HasConstraint(value, chk.Name) {
if err := tx.Migrator().CreateConstraint(value, chk.Name); err != nil {
return err
}
}
}
Expand Down

0 comments on commit 205d638

Please sign in to comment.