-- Create triggers to call broadcast functions for realtime updates

-- Trigger for content_submissions changes
CREATE TRIGGER content_submissions_broadcast
AFTER INSERT OR UPDATE OR DELETE ON public.content_submissions
FOR EACH ROW
EXECUTE FUNCTION broadcast_content_submission_changes();

-- Trigger for submission_items changes  
CREATE TRIGGER submission_items_broadcast
AFTER INSERT OR UPDATE OR DELETE ON public.submission_items
FOR EACH ROW
EXECUTE FUNCTION broadcast_submission_item_changes();

-- Trigger for reports changes
CREATE TRIGGER reports_broadcast
AFTER INSERT OR UPDATE OR DELETE ON public.reports
FOR EACH ROW
EXECUTE FUNCTION broadcast_report_changes();

-- Trigger for reviews changes
CREATE TRIGGER reviews_broadcast
AFTER INSERT OR UPDATE OR DELETE ON public.reviews
FOR EACH ROW
EXECUTE FUNCTION broadcast_review_changes();