mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Remove vendored models in migration service (#74503)
This PR replaces the vendored models in the migration with their equivalent ngalert models. It also replaces the raw SQL selects and inserts with service calls. It also fills in some gaps in the testing suite around: - Migration of alert rules: verifying that the actual data model (queries, conditions) are correct 9a7cfa9 - Secure settings migration: verifying that secure fields remain encrypted for all available notifiers and certain fields migrate from plain text to encrypted secure settings correctly e7d3993 Replacing the checks for custom dashboard ACLs will be replaced in a separate targeted PR as it will be complex enough alone.
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
package ualert
|
||||
|
||||
type dsUIDLookup map[[2]int64]string
|
||||
|
||||
// GetUID fetch thes datasource UID based on orgID+datasourceID
|
||||
func (d dsUIDLookup) GetUID(orgID, datasourceID int64) string {
|
||||
return d[[2]int64{orgID, datasourceID}]
|
||||
}
|
||||
|
||||
// slurpDSIDs returns a map of [orgID, dataSourceId] -> UID.
|
||||
func (m *migration) slurpDSIDs() (dsUIDLookup, error) {
|
||||
dsIDs := []struct {
|
||||
OrgID int64 `xorm:"org_id"`
|
||||
ID int64 `xorm:"id"`
|
||||
UID string `xorm:"uid"`
|
||||
}{}
|
||||
|
||||
err := m.sess.SQL(`SELECT org_id, id, uid FROM data_source`).Find(&dsIDs)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
idToUID := make(dsUIDLookup, len(dsIDs))
|
||||
|
||||
for _, ds := range dsIDs {
|
||||
idToUID[[2]int64{ds.OrgID, ds.ID}] = ds.UID
|
||||
}
|
||||
|
||||
return idToUID, nil
|
||||
}
|
Reference in New Issue
Block a user