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:
co-authored by
Sofia Papagiannaki
parent
cf958e0b4f
commit
6c8ef2a9c2
@@ -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