-- Drop existing policies
DROP POLICY IF EXISTS "Admins can view all provider services" ON provider_services;
DROP POLICY IF EXISTS "Providers can insert own services" ON provider_services;
DROP POLICY IF EXISTS "Providers can update own services" ON provider_services;
DROP POLICY IF EXISTS "Providers can view own services" ON provider_services;

-- New policies using is_user_match function
CREATE POLICY "Admins can view all provider services" ON provider_services
  FOR SELECT TO public USING (is_admin());

CREATE POLICY "Providers can insert own services" ON provider_services
  FOR INSERT TO public WITH CHECK (is_user_match(provider_id));

CREATE POLICY "Providers can update own services" ON provider_services
  FOR UPDATE TO public USING (is_user_match(provider_id));

CREATE POLICY "Providers can view own services" ON provider_services
  FOR SELECT TO public USING (is_user_match(provider_id));
