From cd3d2586f777372c5c2950ce77184c57609f459e Mon Sep 17 00:00:00 2001 From: Karli Date: Tue, 23 Sep 2025 16:24:59 +0300 Subject: [PATCH] fix constraint --- .../20250923162326_analysis_response_elements_fix.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 supabase/migrations/20250923162326_analysis_response_elements_fix.sql diff --git a/supabase/migrations/20250923162326_analysis_response_elements_fix.sql b/supabase/migrations/20250923162326_analysis_response_elements_fix.sql new file mode 100644 index 0000000..cd82c5b --- /dev/null +++ b/supabase/migrations/20250923162326_analysis_response_elements_fix.sql @@ -0,0 +1,9 @@ +-- Drop existing constraint and index for analysis_response_elements +DROP INDEX IF EXISTS "medreport"."analysis_response_elements_unique_by_response_and_element"; +ALTER TABLE "medreport"."analysis_response_elements" +DROP CONSTRAINT IF EXISTS "analysis_response_elements_unique_by_response_and_element"; + +-- Create proper unique constraint that works with ON CONFLICT +ALTER TABLE "medreport"."analysis_response_elements" +ADD CONSTRAINT "analysis_response_elements_unique_by_response_and_element" +UNIQUE ("analysis_response_id", "analysis_element_original_id");