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


-- 为 product_outbound_records 表添加生产批号关联和接手公司字段
ALTER TABLE public.product_outbound_records 
ADD COLUMN IF NOT EXISTS source_batch_id UUID REFERENCES public.product_inventory_records(id) ON DELETE SET NULL,
ADD COLUMN IF NOT EXISTS recipient_company_id UUID REFERENCES public.companies(id) ON DELETE SET NULL,
ADD COLUMN IF NOT EXISTS recipient_company_name TEXT;

-- 创建索引
CREATE INDEX IF NOT EXISTS idx_product_outbound_source_batch ON public.product_outbound_records(source_batch_id);
CREATE INDEX IF NOT EXISTS idx_product_outbound_recipient ON public.product_outbound_records(recipient_company_id);

