{"results":[{"file":"migrations/20260523_124742_create_product_yarn_ratios_table.sql","matches":[{"line":8,"content":"CREATE TABLE IF NOT EXISTS product_yarn_ratios ("},{"line":12,"content":" ratio DECIMAL(5,2) NOT NULL DEFAULT 0,"},{"line":17,"content":"ALTER TABLE product_yarn_ratios ENABLE ROW LEVEL SECURITY;"},{"line":20,"content":"CREATE POLICY company_select_product_yarn_ratios ON product_yarn_ratios FOR SELECT USING (true);"},{"line":21,"content":"CREATE POLICY company_insert_product_yarn_ratios ON product_yarn_ratios FOR INSERT WITH CHECK (true);"},{"line":22,"content":"CREATE POLICY company_update_product_yarn_ratios ON product_yarn_ratios FOR UPDATE USING (true);"},{"line":23,"content":"CREATE POLICY company_delete_product_yarn_ratios ON product_yarn_ratios FOR DELETE USING (true);"}]},{"file":"migrations/20260523_052709_create_plan_tables.sql","matches":[{"line":39,"content":"CREATE TABLE public.yarn_ratios ("},{"line":43,"content":" ratio DECIMAL NOT NULL DEFAULT 1,"}]},{"file":"migrations/20260523_053110_seed_plans_and_related.sql","matches":[{"line":20,"content":"INSERT INTO public.yarn_ratios (plan_id, yarn_name, ratio, amount_per_meter, total_amount) VALUES"}]},{"file":"migrations/20260526_112452_add_yarn_type_to_product_yarn_ratios.sql","matches":[{"line":6,"content":"ALTER TABLE product_yarn_ratios ADD COLUMN IF NOT EXISTS yarn_type TEXT DEFAULT 'all';"}]},{"file":"migrations/20260523_170036_fix_yarn_ratios_select_rls.sql","matches":[{"line":6,"content":"DROP POLICY IF EXISTS users_select_yarn_ratios ON public.yarn_ratios; CREATE POLICY users_select_yarn_ratios ON public.yarn_ratios FOR SELECT USING (EXISTS (SELECT 1 FROM public.production_plans WHERE id = plan_id AND (purchaser_id = public.get_user_master_company_id() OR EXISTS (SELECT 1 FROM public.plan_factories WHERE plan_id = production_plans.id AND factory_id = public.get_user_master_company_id()))));"}]},{"file":"migrations/20260526_112537_add_yarn_type_to_yarn_ratios.sql","matches":[{"line":6,"content":"ALTER TABLE yarn_ratios ADD COLUMN IF NOT EXISTS yarn_type TEXT DEFAULT 'all';"}]},{"file":"migrations/20260523_162926_update_yarn_ratios_rls.sql","matches":[{"line":8,"content":"DROP POLICY IF EXISTS users_select_yarn_ratios ON public.yarn_ratios;"},{"line":9,"content":"DROP POLICY IF EXISTS users_insert_yarn_ratios ON public.yarn_ratios;"},{"line":10,"content":"DROP POLICY IF EXISTS users_delete_yarn_ratios ON public.yarn_ratios;"},{"line":13,"content":"CREATE POLICY users_select_yarn_ratios ON public.yarn_ratios"},{"line":18,"content":"CREATE POLICY users_insert_yarn_ratios ON public.yarn_ratios"},{"line":23,"content":"CREATE POLICY users_update_yarn_ratios ON public.yarn_ratios"},{"line":28,"content":"CREATE POLICY users_delete_yarn_ratios ON public.yarn_ratios"}]},{"file":"migrations/20260523_163000_sync_company_id_data.sql","matches":[{"line":14,"content":"-- 更新 yarn_ratios 的 company_id（通过 production_plans 关联）"},{"line":15,"content":"UPDATE public.yarn_ratios yr"}]},{"file":"migrations/20260523_163054_add_share_link_rls_policies.sql","matches":[{"line":20,"content":"-- yarn_ratios：工厂可以查看关联计划的纱线配比"},{"line":21,"content":"CREATE POLICY factory_select_yarn_ratios_via_share ON public.yarn_ratios"},{"line":25,"content":" WHERE plan_id = yarn_ratios.plan_id"}]},{"file":"migrations/20260523_162846_add_company_id_to_yarn_ratios.sql","matches":[{"line":7,"content":"-- 为 yarn_ratios 表添加 company_id 字段"},{"line":8,"content":"ALTER TABLE public.yarn_ratios ADD COLUMN IF NOT EXISTS company_id UUID REFERENCES public.companies(id) ON DELETE CASCADE;"},{"line":11,"content":"CREATE INDEX IF NOT EXISTS idx_yarn_ratios_company_id ON public.yarn_ratios(company_id);"}]},{"file":"migrations/20260523_162653_drop_remaining_old_policies.sql","matches":[{"line":23,"content":"-- 删除 product_yarn_ratios 表上的旧宽松策略"},{"line":24,"content":"DROP POLICY IF EXISTS company_select_product_yarn_ratios ON public.product_yarn_ratios;"},{"line":25,"content":"DROP POLICY IF EXISTS company_insert_product_yarn_ratios ON public.product_yarn_ratios;"},{"line":26,"content":"DROP POLICY IF EXISTS company_update_product_yarn_ratios ON public.product_yarn_ratios;"},{"line":27,"content":"DROP POLICY IF EXISTS company_delete_product_yarn_ratios ON public.product_yarn_ratios;"}]},{"file":"migrations/20260523_163245_add_missing_rls_policies.sql","matches":[{"line":40,"content":"-- 为 product_yarn_ratios 表添加 RLS 策略"},{"line":41,"content":"CREATE POLICY users_select_product_yarn_ratios ON public.product_yarn_ratios"},{"line":44,"content":"CREATE POLICY users_insert_product_yarn_ratios ON public.product_yarn_ratios"},{"line":47,"content":"CREATE POLICY users_update_product_yarn_ratios ON public.product_yarn_ratios"},{"line":50,"content":"CREATE POLICY users_delete_product_yarn_ratios ON public.product_yarn_ratios"}]},{"file":"migrations/20260523_165901_fix_yarn_ratios_delete_rls.sql","matches":[{"line":6,"content":"DROP POLICY IF EXISTS users_delete_yarn_ratios ON public.yarn_ratios; CREATE POLICY users_delete_yarn_ratios ON public.yarn_ratios FOR DELETE USING (EXISTS (SELECT 1 FROM public.production_plans WHERE id = plan_id AND purchaser_id = public.get_user_master_company_id()));"}]},{"file":"migrations/20260523_163116_fix_share_link_rls_v2.sql","matches":[{"line":9,"content":"DROP POLICY IF EXISTS factory_select_yarn_ratios_via_share ON public.yarn_ratios;"},{"line":10,"content":"DROP POLICY IF EXISTS users_select_yarn_ratios ON public.yarn_ratios;"},{"line":18,"content":"-- yarn_ratios：允许查看（配合计划查看）"},{"line":19,"content":"DROP POLICY IF EXISTS users_select_yarn_ratios ON public.yarn_ratios;"},{"line":20,"content":"DROP POLICY IF EXISTS users_insert_yarn_ratios ON public.yarn_ratios;"},{"line":21,"content":"DROP POLICY IF EXISTS users_update_yarn_ratios ON public.yarn_ratios;"},{"line":22,"content":"DROP POLICY IF EXISTS users_delete_yarn_ratios ON public.yarn_ratios;"},{"line":24,"content":"CREATE POLICY users_select_yarn_ratios ON public.yarn_ratios"},{"line":27,"content":"CREATE POLICY users_insert_yarn_ratios ON public.yarn_ratios"},{"line":32,"content":"CREATE POLICY users_update_yarn_ratios ON public.yarn_ratios"},{"line":37,"content":"CREATE POLICY users_delete_yarn_ratios ON public.yarn_ratios"}]},{"file":"migrations/20260523_052842_enable_rls_all_tables.sql","matches":[{"line":13,"content":"ALTER TABLE public.yarn_ratios ENABLE ROW LEVEL SECURITY;"},{"line":45,"content":"-- yarn_ratios: 所有人可查看和操作"},{"line":46,"content":"CREATE POLICY anon_select_yarn_ratios ON public.yarn_ratios FOR SELECT USING (true);"},{"line":47,"content":"CREATE POLICY anon_insert_yarn_ratios ON public.yarn_ratios FOR INSERT WITH CHECK (true);"},{"line":48,"content":"CREATE POLICY anon_delete_yarn_ratios ON public.yarn_ratios FOR DELETE USING (true);"}]},{"file":"migrations/20260523_162604_create_yarn_rls.sql","matches":[{"line":28,"content":"-- yarn_ratios 表 RLS 策略"},{"line":30,"content":"CREATE POLICY users_select_yarn_ratios ON public.yarn_ratios"},{"line":38,"content":"CREATE POLICY users_insert_yarn_ratios ON public.yarn_ratios"},{"line":46,"content":"CREATE POLICY users_delete_yarn_ratios ON public.yarn_ratios"}]},{"file":"migrations/20260523_162407_drop_old_rls_policies.sql","matches":[{"line":23,"content":"DROP POLICY IF EXISTS anon_select_yarn_ratios ON public.yarn_ratios;"},{"line":24,"content":"DROP POLICY IF EXISTS anon_insert_yarn_ratios ON public.yarn_ratios;"},{"line":25,"content":"DROP POLICY IF EXISTS anon_delete_yarn_ratios ON public.yarn_ratios;"}]}],"pattern":"yarn_ratios|ratio","path":"migrations","totalMatches":62}