mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 03:11:13 -05:00
Fix foreign key constraints
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
-- Drop existing foreign keys that point to auth.users
|
||||
ALTER TABLE public.content_submissions
|
||||
DROP CONSTRAINT IF EXISTS content_submissions_user_id_fkey;
|
||||
|
||||
ALTER TABLE public.content_submissions
|
||||
DROP CONSTRAINT IF EXISTS content_submissions_reviewer_id_fkey;
|
||||
|
||||
ALTER TABLE public.content_submissions
|
||||
DROP CONSTRAINT IF EXISTS content_submissions_assigned_to_fkey;
|
||||
|
||||
ALTER TABLE public.content_submissions
|
||||
DROP CONSTRAINT IF EXISTS content_submissions_escalated_by_fkey;
|
||||
|
||||
-- Create new foreign keys pointing to profiles table
|
||||
ALTER TABLE public.content_submissions
|
||||
ADD CONSTRAINT content_submissions_user_id_fkey
|
||||
FOREIGN KEY (user_id)
|
||||
REFERENCES public.profiles(user_id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE public.content_submissions
|
||||
ADD CONSTRAINT content_submissions_reviewer_id_fkey
|
||||
FOREIGN KEY (reviewer_id)
|
||||
REFERENCES public.profiles(user_id)
|
||||
ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE public.content_submissions
|
||||
ADD CONSTRAINT content_submissions_assigned_to_fkey
|
||||
FOREIGN KEY (assigned_to)
|
||||
REFERENCES public.profiles(user_id)
|
||||
ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE public.content_submissions
|
||||
ADD CONSTRAINT content_submissions_escalated_by_fkey
|
||||
FOREIGN KEY (escalated_by)
|
||||
REFERENCES public.profiles(user_id)
|
||||
ON DELETE SET NULL;
|
||||
Reference in New Issue
Block a user