Dashboard migration: Add missing metrics registration (#110178)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user