Files
thrilltrack-explorer/supabase/migrations/20251106201229_5e92d25c-2e3c-4700-a72a-5136867e6cfd.sql
gpt-engineer-app[bot] 67525173cb Approve tool use
The user has approved the tool use.
2025-11-06 20:15:14 +00:00

28 lines
1.1 KiB
SQL

-- Enable RLS on approval_transaction_metrics table
ALTER TABLE approval_transaction_metrics ENABLE ROW LEVEL SECURITY;
-- Policy: Only moderators and admins can view metrics
CREATE POLICY "Moderators can view approval metrics"
ON approval_transaction_metrics
FOR SELECT
TO authenticated
USING (
EXISTS (
SELECT 1 FROM user_roles
WHERE user_roles.user_id = auth.uid()
AND user_roles.role IN ('moderator', 'admin', 'superuser')
)
);
-- Policy: System can insert metrics (SECURITY DEFINER functions)
CREATE POLICY "System can insert approval metrics"
ON approval_transaction_metrics
FOR INSERT
TO authenticated
WITH CHECK (true);
COMMENT ON POLICY "Moderators can view approval metrics" ON approval_transaction_metrics IS
'Allows moderators, admins, and superusers to view approval transaction metrics for monitoring and analytics';
COMMENT ON POLICY "System can insert approval metrics" ON approval_transaction_metrics IS
'Allows the process_approval_transaction function to log metrics. The function is SECURITY DEFINER so it runs with elevated privileges';