From 1a1dc023b6d6ba94e742a251d81bd5d05661f22a Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 5 May 2023 17:33:12 +0100 Subject: [PATCH] [v10.0.x] Alerting: Migration to not fail if alert_configuration table is not empty (#67937) Alerting: Migration to not fail if alert_configuration table is not empty (#67924) (cherry picked from commit 0ce7f7eaf4b03b04532bdc941e014ea50e2b1788) Co-authored-by: Yuri Tseretyan --- pkg/services/sqlstore/migrations/ualert/ualert.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/services/sqlstore/migrations/ualert/ualert.go b/pkg/services/sqlstore/migrations/ualert/ualert.go index 009a078fb46..38ebaf0ebf1 100644 --- a/pkg/services/sqlstore/migrations/ualert/ualert.go +++ b/pkg/services/sqlstore/migrations/ualert/ualert.go @@ -457,6 +457,9 @@ func (m *migration) writeAlertmanagerConfig(orgID int64, amConfig *PostableUserC return err } + // remove an existing configuration, which could have been left during switching back to legacy alerting + _, _ = m.sess.Delete(AlertConfiguration{OrgID: orgID}) + // We don't need to apply the configuration, given the multi org alertmanager will do an initial sync before the server is ready. _, err = m.sess.Insert(AlertConfiguration{ AlertmanagerConfiguration: string(rawAmConfig),