mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Revert "Alerting: Remove vendored models in migration service" (#76387)
Revert "Alerting: Remove vendored models in migration service (#74503)"
This reverts commit 6a8649d544
.
This commit is contained in:
31
pkg/services/sqlstore/migrations/ualert/datasource.go
Normal file
31
pkg/services/sqlstore/migrations/ualert/datasource.go
Normal file
@@ -0,0 +1,31 @@
|
||||
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