From ac5bcf32ae911e3395f039dddc6bccc0605aab9f Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 5 May 2023 17:34:14 +0100 Subject: [PATCH] [v9.5.x] Alerting: Migration to not fail if alert_configuration table is not empty (#67936) 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 03a4ee47834..ecef514ef16 100644 --- a/pkg/services/sqlstore/migrations/ualert/ualert.go +++ b/pkg/services/sqlstore/migrations/ualert/ualert.go @@ -459,6 +459,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),