From edb00c10adff38445c4350c0cb524faa6ec2d592 Mon Sep 17 00:00:00 2001 From: Googol Lee Date: Wed, 14 Sep 2022 04:26:51 +0200 Subject: [PATCH] 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> --- migrator/migrator.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/migrator/migrator.go b/migrator/migrator.go index c1d7e0e75..e6782a13b 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -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 } } }