-- Migration 011: Add context fields to extraction_lines
-- These fields capture additional context information from invoice line items

ALTER TABLE extraction_lines
ADD COLUMN IF NOT EXISTS ip_address VARCHAR(50),
ADD COLUMN IF NOT EXISTS contract_number VARCHAR(100),
ADD COLUMN IF NOT EXISTS location_street VARCHAR(255),
ADD COLUMN IF NOT EXISTS location_zip VARCHAR(10),
ADD COLUMN IF NOT EXISTS location_city VARCHAR(100);

-- Add index for contract number lookups
CREATE INDEX IF NOT EXISTS idx_extraction_lines_contract_number ON extraction_lines(contract_number);

COMMENT ON COLUMN extraction_lines.ip_address IS 'IP address/subnet from line context (e.g., 152.115.56.192/27)';
COMMENT ON COLUMN extraction_lines.contract_number IS 'Contract number from line context (e.g., NKA-008225)';
COMMENT ON COLUMN extraction_lines.location_street IS 'Street address from line context';
COMMENT ON COLUMN extraction_lines.location_zip IS 'Zip code from line context';
COMMENT ON COLUMN extraction_lines.location_city IS 'City from line context';
