{"-- Safely create policies for super admin visibility
DO $$
BEGIN
  IF NOT EXISTS (
    SELECT 1 FROM pg_policies 
    WHERE schemaname = 'public' AND tablename = 'form_assignments' AND policyname = 'Super admin can view all form assignments'
  ) THEN
    CREATE POLICY \"Super admin can view all form assignments\"
    ON public.form_assignments
    FOR SELECT
    USING (is_current_user_super_admin());
  END IF;

  IF NOT EXISTS (
    SELECT 1 FROM pg_policies 
    WHERE schemaname = 'public' AND tablename = 'branches' AND policyname = 'Super admin can view all branches'
  ) THEN
    CREATE POLICY \"Super admin can view all branches\"
    ON public.branches
    FOR SELECT
    USING (is_current_user_super_admin());
  END IF;
END $$"}