This commit is contained in:
@@ -31,11 +31,11 @@ func (s *Store) EnsureLibraryOperation(ctx context.Context, op governance.Librar
|
||||
}
|
||||
var id string
|
||||
err := s.db.QueryRow(ctx, `
|
||||
INSERT INTO library_operations (id, scope, kind, target_snapshot_id, request_digest, operation_key, actor, created_at)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8)
|
||||
INSERT INTO library_operations (id, scope, kind, target_snapshot_id, request_digest, operation_key, actor, created_at, target_id)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)
|
||||
ON CONFLICT (scope, kind, operation_key) DO NOTHING
|
||||
RETURNING id`, op.ID, op.Scope, string(op.Kind), op.TargetSnapshotID, op.RequestDigest,
|
||||
op.OperationKey, op.Actor, op.CreatedAt.UTC()).Scan(&id)
|
||||
op.OperationKey, op.Actor, op.CreatedAt.UTC(), s.libraryTargetID).Scan(&id)
|
||||
if err == nil {
|
||||
return op, true, nil
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (s *Store) LibraryOperation(ctx context.Context, id string) (governance.Lib
|
||||
var kind string
|
||||
err := s.db.QueryRow(ctx, `
|
||||
SELECT id, scope, kind, target_snapshot_id, request_digest, operation_key, actor, created_at
|
||||
FROM library_operations WHERE id=$1`, id).Scan(&op.ID, &op.Scope, &kind, &op.TargetSnapshotID,
|
||||
FROM library_operations WHERE id=$1 AND (kind='seal' OR target_id=$2)`, id, s.libraryTargetID).Scan(&op.ID, &op.Scope, &kind, &op.TargetSnapshotID,
|
||||
&op.RequestDigest, &op.OperationKey, &op.Actor, &op.CreatedAt)
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
|
||||
Reference in New Issue
Block a user