AutoMigrate() should always migrate checks, even there is no relationship constraints. (#5644)

* fix: remove uuid autoincrement

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

Co-authored-by: a631807682 <631807682@qq.com>
This commit is contained in:
Googol Lee 2022-09-14 04:26:51 +02:00 committed by GitHub
parent f29afdd329
commit edb00c10ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -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
}
}
}