From edba074b380766baa01fbad71d35a7c1ebfe4006 Mon Sep 17 00:00:00 2001 From: Karli Date: Tue, 23 Sep 2025 16:05:11 +0300 Subject: [PATCH] fix medipost_actions constraint --- ...143000_fix_medipost_actions_unique_constraint.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 supabase/migrations/20250923143000_fix_medipost_actions_unique_constraint.sql diff --git a/supabase/migrations/20250923143000_fix_medipost_actions_unique_constraint.sql b/supabase/migrations/20250923143000_fix_medipost_actions_unique_constraint.sql new file mode 100644 index 0000000..751c636 --- /dev/null +++ b/supabase/migrations/20250923143000_fix_medipost_actions_unique_constraint.sql @@ -0,0 +1,12 @@ +-- Fix medipost_actions unique constraint to work with ON CONFLICT +-- The previous partial index cannot be used with ON CONFLICT clause + +-- Drop the existing partial unique index +DROP INDEX IF EXISTS "medreport"."medipost_actions_unique_by_private_message_id"; + +-- Create a proper unique constraint that can be used with ON CONFLICT +-- PostgreSQL unique constraints allow multiple NULL values by default +-- This will enforce uniqueness for non-NULL values while allowing multiple NULLs +ALTER TABLE "medreport"."medipost_actions" +ADD CONSTRAINT "medipost_actions_unique_by_private_message_id" +UNIQUE ("medipost_private_message_id");