From 205d6389740721b6ea3930d1ad3c3724531f8e8b Mon Sep 17 00:00:00 2001 From: Googol Lee Date: Thu, 25 Aug 2022 15:45:31 +0200 Subject: [PATCH] AutoMigrate() should always migrate checks, even there is no relationship constranits. --- migrator/migrator.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/migrator/migrator.go b/migrator/migrator.go index 87ac77451..880f391d1 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 } } }