From bb02991b05570041a592f77ffe4f5cd95e2ee4e2 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:38:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#4569)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #4568 --- backend/init/migration/migrations/v_1_10.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/init/migration/migrations/v_1_10.go b/backend/init/migration/migrations/v_1_10.go index 0687c288f429..0e84b64ffb2e 100644 --- a/backend/init/migration/migrations/v_1_10.go +++ b/backend/init/migration/migrations/v_1_10.go @@ -74,8 +74,10 @@ var NewMonitorDB = &gormigrate.Migration{ } else { itemData = bases[200*i:] } - if err := global.MonitorDB.Create(&itemData).Error; err != nil { - return err + if len(itemData) != 0 { + if err := global.MonitorDB.Create(&itemData).Error; err != nil { + return err + } } } } @@ -87,8 +89,10 @@ var NewMonitorDB = &gormigrate.Migration{ } else { itemData = ios[200*i:] } - if err := global.MonitorDB.Create(&itemData).Error; err != nil { - return err + if len(itemData) != 0 { + if err := global.MonitorDB.Create(&itemData).Error; err != nil { + return err + } } } } @@ -100,8 +104,10 @@ var NewMonitorDB = &gormigrate.Migration{ } else { itemData = networks[200*i:] } - if err := global.MonitorDB.Create(&itemData).Error; err != nil { - return err + if len(itemData) != 0 { + if err := global.MonitorDB.Create(&itemData).Error; err != nil { + return err + } } } }