Unistore: Add generation column (#102222)

This commit is contained in:
Ryan McKinley
2025-04-01 20:38:23 +03:00
committed by GitHub
parent cd30742616
commit 9c49c601f1
19 changed files with 194 additions and 87 deletions
+4 -1
View File
@@ -11,7 +11,6 @@ import (
"github.com/go-sql-driver/mysql"
"github.com/google/uuid"
unifiedbackend "github.com/grafana/grafana/pkg/storage/unified/backend"
"github.com/jackc/pgx/v5/pgconn"
"github.com/lib/pq"
"github.com/mattn/go-sqlite3"
@@ -22,6 +21,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
"github.com/grafana/grafana/pkg/infra/log"
unifiedbackend "github.com/grafana/grafana/pkg/storage/unified/backend"
"github.com/grafana/grafana/pkg/storage/unified/resource"
"github.com/grafana/grafana/pkg/storage/unified/sql/db"
"github.com/grafana/grafana/pkg/storage/unified/sql/dbutil"
@@ -353,6 +353,7 @@ func (b *backend) create(ctx context.Context, event resource.WriteEvent) (int64,
SQLTemplate: sqltemplate.New(b.dialect),
WriteEvent: event,
Folder: folder,
Generation: event.Object.GetGeneration(),
GUID: guid,
}); err != nil {
return guid, fmt.Errorf("insert into resource history: %w", err)
@@ -441,6 +442,7 @@ func (b *backend) update(ctx context.Context, event resource.WriteEvent) (int64,
WriteEvent: event,
Folder: folder,
GUID: guid,
Generation: event.Object.GetGeneration(),
}); err != nil {
return guid, fmt.Errorf("insert into resource history: %w", err)
}
@@ -494,6 +496,7 @@ func (b *backend) delete(ctx context.Context, event resource.WriteEvent) (int64,
WriteEvent: event,
Folder: folder,
GUID: guid,
Generation: 0, // object does not exist
}); err != nil {
return guid, fmt.Errorf("insert into resource history: %w", err)
}