fix: Makes created and updated by nullable strings for library panel migration (#108122)

Signed-off-by: Bruno Abrantes <bruno@brunoabrantes.com>
This commit is contained in:
Bruno Abrantes
2025-07-15 16:30:31 +02:00
committed by GitHub
parent d602e79e9a
commit c06c1b1e8a
2 changed files with 73 additions and 9 deletions
@@ -489,10 +489,10 @@ type panel struct {
FolderUID sql.NullString
Created time.Time
CreatedBy string
CreatedBy sql.NullString
Updated time.Time
UpdatedBy string
UpdatedBy sql.NullString
Version int64
@@ -633,13 +633,13 @@ func parseLibraryPanelRow(p panel) (dashboardV0.LibraryPanel, error) {
if p.FolderUID.Valid {
meta.SetFolder(p.FolderUID.String)
}
meta.SetCreatedBy(p.CreatedBy)
meta.SetCreatedBy(getUserID(p.CreatedBy, sql.NullInt64{}))
meta.SetGeneration(p.Version)
meta.SetDeprecatedInternalID(p.ID) //nolint:staticcheck
// Only set updated metadata if it is different
if p.UpdatedBy != p.CreatedBy || p.Updated.Sub(p.Created) > time.Second {
meta.SetUpdatedBy(p.UpdatedBy)
if p.UpdatedBy.Valid && p.Updated.Sub(p.Created) > time.Second {
meta.SetUpdatedBy(getUserID(p.UpdatedBy, sql.NullInt64{}))
meta.SetUpdatedTimestamp(&p.Updated)
}