Skip to content

Commit

Permalink
delete custom rule
Browse files Browse the repository at this point in the history
  • Loading branch information
hasa1K committed Jul 27, 2023
1 parent aa530cd commit 75dd528
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sqle/model/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,3 +596,17 @@ func (s *Storage) GetAllRulesByTmpNameAndProjectIdInstanceDBType(ruleTemplateNam
}
return rules, customRules, nil
}

func (s *Storage) DeleteCustomRule(ruleId string) error {
tx := s.db.Begin()
if err := tx.Where("rule_id = ?", ruleId).Delete(&CustomRule{}).Error; err != nil {
tx.Rollback()
return err
}
if err := tx.Where("rule_id = ?", ruleId).Delete(&RuleTemplateCustomRule{}).Error; err != nil {
tx.Rollback()
return err
}

return errors.New(errors.ConnectStorageError, tx.Commit().Error)
}

0 comments on commit 75dd528

Please sign in to comment.