-- Add nozzle-specific fields to user_equipment table
-- This migration adds columns to capture nozzle specifications when equipment category is 'Nozzle'

ALTER TABLE user_equipment 
ADD COLUMN IF NOT EXISTS orifice_size VARCHAR(20),
ADD COLUMN IF NOT EXISTS spray_angle INTEGER,
ADD COLUMN IF NOT EXISTS flow_rate_gpm DECIMAL(6, 3),
ADD COLUMN IF NOT EXISTS droplet_size VARCHAR(50) CHECK (droplet_size IN ('fine', 'medium', 'coarse', 'very_coarse', 'extremely_coarse')),
ADD COLUMN IF NOT EXISTS spray_pattern VARCHAR(50) CHECK (spray_pattern IN ('flat_fan', 'hollow_cone', 'full_cone', 'flooding')),
ADD COLUMN IF NOT EXISTS pressure_range_psi VARCHAR(50),
ADD COLUMN IF NOT EXISTS thread_size VARCHAR(20),
ADD COLUMN IF NOT EXISTS material VARCHAR(50) CHECK (material IN ('polymer', 'stainless_steel', 'brass', 'ceramic')),
ADD COLUMN IF NOT EXISTS color_code VARCHAR(50),
ADD COLUMN IF NOT EXISTS quantity_owned INTEGER DEFAULT 1;

-- Create index for better performance when filtering nozzles
CREATE INDEX IF NOT EXISTS idx_user_equipment_nozzle_specs ON user_equipment(orifice_size, droplet_size, spray_angle) WHERE orifice_size IS NOT NULL;

SELECT 'Nozzle fields added to user_equipment table successfully!' as migration_status;