-- Fix INSERT policy for task_activity_logs: WITH CHECK only for INSERT
DO $$
BEGIN
  IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='task_activity_logs') THEN
    EXECUTE 'ALTER TABLE IF EXISTS public.task_activity_logs ENABLE ROW LEVEL SECURITY';
    EXECUTE 'DROP POLICY IF EXISTS allow_authenticated_inserts ON public.task_activity_logs';
    EXECUTE 'CREATE POLICY allow_authenticated_inserts ON public.task_activity_logs FOR INSERT TO authenticated WITH CHECK (true)';
  END IF;
END
$$;
