-- Migration: 00012_verification_records_rls
-- Description: Ensure RLS policies prevent user tampering on verification_records
-- Date: 2025-02-14

ALTER TABLE verification_records ENABLE ROW LEVEL SECURITY;
ALTER TABLE verification_records FORCE ROW LEVEL SECURITY;

DROP POLICY IF EXISTS "Users can view own verification records" ON verification_records;
DROP POLICY IF EXISTS "Service role can manage verification records" ON verification_records;

CREATE POLICY "Users can view own verification records"
  ON verification_records FOR SELECT
  USING (user_id = auth.uid());

CREATE POLICY "Service role can manage verification records"
  ON verification_records FOR ALL
  USING (auth.role() = 'service_role')
  WITH CHECK (auth.role() = 'service_role');
