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 }