-- Parche: Asociar Factura de Proveedor con Órdenes de Compra/Servicio
-- Ejecutar en la base de datos (PostgreSQL)

BEGIN;

ALTER TABLE public.purchases_bills 
ADD COLUMN IF NOT EXISTS purchase_order_id UUID NULL REFERENCES public.purchase_orders(id) ON DELETE SET NULL;

CREATE INDEX IF NOT EXISTS idx_purchases_bills_purchase_order ON public.purchases_bills(purchase_order_id);

COMMIT;
