Alerting: cleanup alert resources on org removal (#39938) (#40321)

(cherry picked from commit e1dfec49f9)

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2021-10-12 12:46:03 +02:00
committed by GitHub
co-authored by Jean-Philippe Quéméner
parent fa4eec8e1d
commit 128981fb21
4 changed files with 113 additions and 25 deletions
+11
View File
@@ -241,6 +241,17 @@ func DeleteOrg(cmd *models.DeleteOrgCommand) error {
"DELETE FROM org_user WHERE org_id = ?",
"DELETE FROM org WHERE id = ?",
"DELETE FROM temp_user WHERE org_id = ?",
"DELETE FROM ngalert_configuration WHERE org_id = ?",
"DELETE FROM alert_configuration WHERE org_id = ?",
"DELETE FROM alert_instance WHERE rule_org_id = ?",
"DELETE FROM alert_notification WHERE org_id = ?",
"DELETE FROM alert_notification_state WHERE org_id = ?",
"DELETE FROM alert_rule WHERE org_id = ?",
"DELETE FROM alert_rule_tag WHERE EXISTS (SELECT 1 FROM alert WHERE alert.org_id = ? AND alert.id = alert_rule_tag.alert_id)",
"DELETE FROM alert_rule_version WHERE rule_org_id = ?",
"DELETE FROM alert WHERE org_id = ?",
"DELETE FROM annotation WHERE org_id = ?",
"DELETE FROM kv_store WHERE org_id = ?",
}
for _, sql := range deletes {