From d380e6a3cd7109e71732f3bdc5dd42b919fec6fe Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Tue, 24 Feb 2026 05:34:42 +0300 Subject: [PATCH] fix: correct cancel_reason column name to cancellation_reason Also add migration to drop remaining auth.users FK constraints on p2p_messages, notifications, ratings, audit_log tables. --- shared/lib/p2p-fiat.ts | 2 +- .../20260224050000_drop_remaining_auth_fk.sql | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 web/supabase/migrations/20260224050000_drop_remaining_auth_fk.sql diff --git a/shared/lib/p2p-fiat.ts b/shared/lib/p2p-fiat.ts index 3f8ea583..246a3b62 100644 --- a/shared/lib/p2p-fiat.ts +++ b/shared/lib/p2p-fiat.ts @@ -888,7 +888,7 @@ export async function cancelTrade( .update({ status: 'cancelled', cancelled_by: cancelledBy, - cancel_reason: reason, + cancellation_reason: reason, }) .eq('id', tradeId); diff --git a/web/supabase/migrations/20260224050000_drop_remaining_auth_fk.sql b/web/supabase/migrations/20260224050000_drop_remaining_auth_fk.sql new file mode 100644 index 00000000..1978dc91 --- /dev/null +++ b/web/supabase/migrations/20260224050000_drop_remaining_auth_fk.sql @@ -0,0 +1,31 @@ +-- Migration: Drop remaining auth.users FK constraints missed in 20260223120000 +-- These tables still reference auth.users(id) but use wallet-based UUID v5 identity + +-- 1. p2p_messages.sender_id (blocks chat) +ALTER TABLE public.p2p_messages + DROP CONSTRAINT IF EXISTS p2p_messages_sender_id_fkey; + +-- 2. p2p_notifications.user_id (blocks notifications) +DO $$ BEGIN + IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'p2p_notifications') THEN + ALTER TABLE public.p2p_notifications DROP CONSTRAINT IF EXISTS p2p_notifications_user_id_fkey; + END IF; +END $$; + +-- 3. p2p_ratings.rater_id, rated_id +DO $$ BEGIN + IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'p2p_ratings') THEN + ALTER TABLE public.p2p_ratings DROP CONSTRAINT IF EXISTS p2p_ratings_rater_id_fkey; + ALTER TABLE public.p2p_ratings DROP CONSTRAINT IF EXISTS p2p_ratings_rated_id_fkey; + END IF; +END $$; + +-- 4. p2p_audit_log.user_id +DO $$ BEGIN + IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'p2p_audit_log') THEN + ALTER TABLE public.p2p_audit_log DROP CONSTRAINT IF EXISTS p2p_audit_log_user_id_fkey; + END IF; +END $$; + +-- 5. Drop old auth.uid() RLS policy on p2p_messages (replaced by open policy) +DROP POLICY IF EXISTS "p2p_messages_trade_participants" ON public.p2p_messages;