mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Alert Rule migration (#33000)
* Not complete, put migration behind env flag for now: UALERT_MIG=iDidBackup * Important to backup, and not expect the same DB to keep working until the env trigger is removed. * Alerting: Migrate dashboard alert permissions * Do not use imported models * Change folder titles Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
This commit is contained in:
25
pkg/services/sqlstore/migrations/ualert/datasource.go
Normal file
25
pkg/services/sqlstore/migrations/ualert/datasource.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package ualert
|
||||
|
||||
// slurpDSIDs returns a map of [orgID, dataSourceId] -> [UID, Name].
|
||||
func (m *migration) slurpDSIDs() (map[[2]int64][2]string, error) {
|
||||
dsIDs := []struct {
|
||||
OrgID int64 `xorm:"org_id"`
|
||||
ID int64 `xorm:"id"`
|
||||
UID string `xorm:"uid"`
|
||||
Name string
|
||||
}{}
|
||||
|
||||
err := m.sess.SQL(`SELECT org_id, id, uid, name FROM data_source`).Find(&dsIDs)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
idToUID := make(map[[2]int64][2]string, len(dsIDs))
|
||||
|
||||
for _, ds := range dsIDs {
|
||||
idToUID[[2]int64{ds.OrgID, ds.ID}] = [2]string{ds.UID, ds.Name}
|
||||
}
|
||||
|
||||
return idToUID, nil
|
||||
}
|
Reference in New Issue
Block a user