Dashboard migration: Add missing metrics registration (#110178)

This commit is contained in:
Dominik Prokop
2025-08-29 18:37:39 -06:00
committed by GitHub
parent b22f15ad16
commit 398ed84a60
13 changed files with 1504 additions and 90 deletions
+5 -3
View File
@@ -1,6 +1,7 @@
package migration
import (
"fmt"
"sync"
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
@@ -39,7 +40,7 @@ func (m *migrator) init(dsInfoProvider schemaversion.DataSourceInfoProvider, pan
func (m *migrator) migrate(dash map[string]interface{}, targetVersion int) error {
if dash == nil {
return schemaversion.NewMigrationError("dashboard is nil", 0, targetVersion)
return schemaversion.NewMigrationError("dashboard is nil", 0, targetVersion, "")
}
// wait for the migrator to be initialized
@@ -57,14 +58,15 @@ func (m *migrator) migrate(dash map[string]interface{}, targetVersion int) error
for nextVersion := inputVersion + 1; nextVersion <= targetVersion; nextVersion++ {
if migration, ok := m.migrations[nextVersion]; ok {
if err := migration(dash); err != nil {
return schemaversion.NewMigrationError("migration failed: "+err.Error(), inputVersion, nextVersion)
functionName := fmt.Sprintf("V%d", nextVersion)
return schemaversion.NewMigrationError("migration failed: "+err.Error(), inputVersion, nextVersion, functionName)
}
dash["schemaVersion"] = nextVersion
}
}
if schemaversion.GetSchemaVersion(dash) != targetVersion {
return schemaversion.NewMigrationError("schema version not migrated to target version", inputVersion, targetVersion)
return schemaversion.NewMigrationError("schema version not migrated to target version", inputVersion, targetVersion, "")
}
return nil