mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
Alerting: Fix migration to create rules with group index 1 (#56511)
This commit is contained in:
parent
e2f1201382
commit
3487e68d15
@ -122,6 +122,7 @@ func (m *migration) makeAlertRule(cond condition, da dashAlert, folderUID string
|
||||
Updated: time.Now().UTC(),
|
||||
Annotations: annotations,
|
||||
Labels: lbls,
|
||||
RuleGroupIndex: 1,
|
||||
}
|
||||
|
||||
ar.NoDataState, err = transNoData(da.ParsedSettings.NoDataState)
|
||||
|
@ -839,7 +839,7 @@ func (c updateRulesOrderInGroup) Exec(sess *xorm.Session, migrator *migrator.Mig
|
||||
}
|
||||
|
||||
updated := time.Now()
|
||||
versions := make([]*alertRuleVersion, 0, len(toUpdate))
|
||||
versions := make([]interface{}, 0, len(toUpdate))
|
||||
|
||||
for _, rule := range toUpdate {
|
||||
rule.Updated = updated
|
||||
@ -855,8 +855,7 @@ func (c updateRulesOrderInGroup) Exec(sess *xorm.Session, migrator *migrator.Mig
|
||||
migrator.Logger.Debug("updated group index for alert rule", "rule_uid", rule.UID)
|
||||
versions = append(versions, version)
|
||||
}
|
||||
|
||||
_, err := sess.Insert(&versions)
|
||||
_, err := sess.Insert(versions...)
|
||||
if err != nil {
|
||||
migrator.Logger.Error("failed to insert changes to alert_rule_version", "err", err)
|
||||
return fmt.Errorf("unable to update alert rules with group index: %w", err)
|
||||
|
Loading…
Reference in New Issue
Block a user