feat: [AH-786]: Updated Layer query to fix allowing duplicate layers (#3253)

* [AH-786]: Updated Layer query to fix allowing duplicate layers
BT-10437
Arvind Choudhary 2025-01-14 06:19:29 +00:00 committed by Harness
parent e9a7fd1e88
commit 362e64fd62
1 changed files with 5 additions and 3 deletions

View File

@ -56,8 +56,10 @@ type layersDB struct {
UpdatedBy int64 `db:"layer_updated_by"`
}
func (l layersDao) AssociateLayerBlob(ctx context.Context, m *types.Manifest,
b *types.Blob) error {
func (l layersDao) AssociateLayerBlob(
ctx context.Context, m *types.Manifest,
b *types.Blob,
) error {
const sqlQuery = `
INSERT INTO layers (
layer_registry_id
@ -80,7 +82,7 @@ func (l layersDao) AssociateLayerBlob(ctx context.Context, m *types.Manifest,
,:layer_created_by
,:layer_updated_by
) ON CONFLICT (layer_registry_id, layer_manifest_id, layer_blob_id)
DO NOTHING
DO UPDATE SET layer_registry_id = EXCLUDED.layer_registry_id
RETURNING layer_id`
mediaTypeID, err := l.mtRepository.MapMediaType(ctx, b.MediaType)