From ed11c0a4a66b5b6907bf6946d2a85207631b3036 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Tue, 14 Mar 2023 18:17:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=88=A0=E9=99=A4MYSQ?= =?UTF-8?q?L=E5=BA=94=E7=94=A8=E6=B2=A1=E6=9C=89=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=A1=A8=E6=95=B0=E6=8D=AE=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/repo/databse_mysql.go | 5 +++++ backend/app/service/app_utils.go | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/app/repo/databse_mysql.go b/backend/app/repo/databse_mysql.go index b31216cbc..281704953 100644 --- a/backend/app/repo/databse_mysql.go +++ b/backend/app/repo/databse_mysql.go @@ -19,6 +19,7 @@ type IMysqlRepo interface { Delete(ctx context.Context, opts ...DBOption) error Update(id uint, vars map[string]interface{}) error UpdateDatabaseInfo(id uint, vars map[string]interface{}) error + DeleteAll(ctx context.Context) error } func NewIMysqlRepo() IMysqlRepo { @@ -65,6 +66,10 @@ func (u *MysqlRepo) Delete(ctx context.Context, opts ...DBOption) error { return getTx(ctx, opts...).Delete(&model.DatabaseMysql{}).Error } +func (u *MysqlRepo) DeleteAll(ctx context.Context) error { + return getTx(ctx).Where("1 = 1").Delete(&model.DatabaseMysql{}).Error +} + func (u *MysqlRepo) Update(id uint, vars map[string]interface{}) error { return global.DB.Model(&model.DatabaseMysql{}).Where("id = ?", id).Updates(vars).Error } diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index dd5cca43f..181974030 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -161,7 +161,9 @@ func deleteAppInstall(ctx context.Context, install model.AppInstall, deleteBacku } _ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType("app"), commonRepo.WithByName(install.App.Key), backupRepo.WithByDetailName(install.Name)) _ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType(install.App.Key)) - + if install.App.Key == constant.AppMysql { + _ = mysqlRepo.DeleteAll(ctx) + } return nil }