Fix duplicate row index on upsert statement #213

Merged
bustikiller merged 2 commits from fix-upsert-index into main 2025-01-14 22:11:43 +00:00
Showing only changes of commit c6c5a87d8b - Show all commits

View File

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