-- ============================================
-- 此文件由 Meoo Cloud 自动生成，请勿修改
-- This file is auto-generated by Meoo Cloud, DO NOT MODIFY
-- ============================================

DROP POLICY IF EXISTS anon_select_companies ON companies; CREATE POLICY purchaser_select_linked_companies ON companies FOR SELECT USING (EXISTS (SELECT 1 FROM company_relationships WHERE company_relationships.purchaser_company_id = get_user_master_company_id() AND company_relationships.factory_company_id = companies.id AND company_relationships.status = 'active') OR companies.id = get_user_master_company_id() OR companies.role = 'purchaser'); CREATE POLICY factory_select_linked_companies ON companies FOR SELECT USING (EXISTS (SELECT 1 FROM company_relationships WHERE company_relationships.factory_company_id = get_user_master_company_id() AND company_relationships.purchaser_company_id = companies.id AND company_relationships.status = 'active') OR companies.id = get_user_master_company_id());
