Alerting: Change rule migration to be based on feature flag (#33792)

makes it so the feature flag can be turned on off, and the migration will be cleared and rerun. All existing NG alert rules, configuration settings, etc are removed when disabling the feature flag.
for https://github.com/grafana/alerting-squad/issues/142

Co-authored-by: Sofia Papagiannaki <sofia@grafana.com>
This commit is contained in:
Kyle Brandt
2021-05-11 08:08:39 -04:00
committed by GitHub
parent ac44a679a7
commit dc3e17ba5b
5 changed files with 95 additions and 8 deletions

View File

@@ -44,7 +44,6 @@ func (m *migration) createFolder(orgID int64, title string) (*dashboard, error)
}),
}
dash := cmd.getDashboardModel()
var userId int64 = -1
uid, err := m.generateNewDashboardUid(dash.OrgId)
if err != nil {
@@ -55,9 +54,9 @@ func (m *migration) createFolder(orgID int64, title string) (*dashboard, error)
parentVersion := dash.Version
dash.setVersion(1)
dash.Created = time.Now()
dash.CreatedBy = userId
dash.CreatedBy = FOLDER_CREATED_BY
dash.Updated = time.Now()
dash.UpdatedBy = userId
dash.UpdatedBy = FOLDER_CREATED_BY
metrics.MApiDashboardInsert.Inc()
if _, err = m.sess.Insert(dash); err != nil {