mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 13:11:12 -05:00
Fix review lifecycle tracking
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
-- Update review_deletions table to use correct column name
|
||||
ALTER TABLE public.review_deletions
|
||||
RENAME COLUMN review_text TO content;
|
||||
|
||||
-- Update the trigger function to use correct column name
|
||||
CREATE OR REPLACE FUNCTION public.log_review_deletion()
|
||||
RETURNS TRIGGER
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
SET search_path = public
|
||||
AS $$
|
||||
BEGIN
|
||||
-- Insert into review_deletions table
|
||||
INSERT INTO public.review_deletions (
|
||||
review_id,
|
||||
user_id,
|
||||
park_id,
|
||||
ride_id,
|
||||
rating,
|
||||
content,
|
||||
deleted_by,
|
||||
deletion_reason,
|
||||
was_moderated,
|
||||
created_at
|
||||
) VALUES (
|
||||
OLD.id,
|
||||
OLD.user_id,
|
||||
OLD.park_id,
|
||||
OLD.ride_id,
|
||||
OLD.rating,
|
||||
OLD.content,
|
||||
auth.uid(),
|
||||
CASE
|
||||
WHEN OLD.moderation_status = 'rejected' THEN 'Rejected by moderator'
|
||||
ELSE 'Deleted by user or admin'
|
||||
END,
|
||||
OLD.moderation_status != 'approved',
|
||||
OLD.created_at
|
||||
);
|
||||
|
||||
RETURN OLD;
|
||||
END;
|
||||
$$;
|
||||
Reference in New Issue
Block a user