AlertMigration: remove alert_rule UID db check (#33568)

do not believe this is needed due to uniqueness promised by shortid lib
since there is no provisioning yet. https://github.com/teris-io/shortid
This commit is contained in:
Kyle Brandt 2021-04-30 13:35:26 -04:00 committed by GitHub
parent b8f01fe034
commit c25eab4eda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,13 +49,10 @@ func (m *migration) makeAlertRule(cond condition, da dashAlert, folderUID string
For: duration(da.For),
Updated: time.Now().UTC(),
Annotations: annotations,
}
var err error
ar.Uid, err = m.generateAlertRuleUID(ar.OrgId)
if err != nil {
return nil, err
Uid: util.GenerateShortUID(),
}
var err error
ar.NoDataState, err = transNoData(da.ParsedSettings.NoDataState)
if err != nil {
return nil, err
@ -69,25 +66,6 @@ func (m *migration) makeAlertRule(cond condition, da dashAlert, folderUID string
return ar, nil
}
func (m *migration) generateAlertRuleUID(orgId int64) (string, error) {
for i := 0; i < 20; i++ {
uid := util.GenerateShortUID()
exists, err := m.sess.Where("org_id=? AND uid=?", orgId, uid).Get(&alertRule{})
if err != nil {
return "", err
}
if !exists {
return uid, nil
}
}
return "", fmt.Errorf("could not generate unique uid for alert rule")
}
// TODO: Do I need to create an initial alertRuleVersion as well?
type alertQuery struct {
// RefID is the unique identifier of the query, set by the frontend call.
RefID string `json:"refId"`