Fix duplicate row index on upsert statement
Some checks failed
Add copyright notice / copyright_notice (pull_request) Successful in 1m22s
Run unit tests / unit_tests (pull_request) Successful in 2m59s
Build Nginx-based docker image / build-static-assets (pull_request) Failing after 8m46s
Check usage of free licenses / check-licenses (pull_request) Successful in 1m49s

This commit is contained in:
Manuel Bustillo 2025-01-14 19:13:40 +01:00
parent acf3b7b82a
commit c6c5a87d8b

View File

@ -26,7 +26,7 @@ class AffinitiesController < ApplicationController
}
end
GroupAffinity.upsert_all(affinities)
GroupAffinity.upsert_all(affinities, unique_by: :uindex_group_pair)
render json: {}, status: :ok
rescue ActiveRecord::InvalidForeignKey
@ -50,7 +50,7 @@ class AffinitiesController < ApplicationController
}
end
GroupAffinity.upsert_all(affinities)
GroupAffinity.upsert_all(affinities, unique_by: :uindex_group_pair)
render json: {}, status: :ok
end