AutoMigrate() should always migrate checks, even there is no relationship constranits.

This commit is contained in:
Googol Lee 2022-08-25 15:45:31 +02:00
parent 1400547b7e
commit 205d638974

View File

@ -135,12 +135,12 @@ func (m Migrator) AutoMigrate(values ...interface{}) error {
} }
} }
} }
}
for _, chk := range stmt.Schema.ParseCheckConstraints() { for _, chk := range stmt.Schema.ParseCheckConstraints() {
if !tx.Migrator().HasConstraint(value, chk.Name) { if !tx.Migrator().HasConstraint(value, chk.Name) {
if err := tx.Migrator().CreateConstraint(value, chk.Name); err != nil { if err := tx.Migrator().CreateConstraint(value, chk.Name); err != nil {
return err return err
}
} }
} }
} }