From c6c5a87d8bffc2ff2d302292f36d4bc90d5a3d10 Mon Sep 17 00:00:00 2001 From: Manuel Bustillo Date: Tue, 14 Jan 2025 19:13:40 +0100 Subject: [PATCH] Fix duplicate row index on upsert statement --- app/controllers/affinities_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/affinities_controller.rb b/app/controllers/affinities_controller.rb index 7d63e9e..1412423 100644 --- a/app/controllers/affinities_controller.rb +++ b/app/controllers/affinities_controller.rb @@ -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