-- Add connectivity fields to sites table for site connectivity QC
-- Run this script against your database to add the required columns

-- Add connectivity_status column (connected/disconnected)
ALTER TABLE eli_test.sites 
ADD COLUMN IF NOT EXISTS connectivity_status VARCHAR(20) DEFAULT NULL;

-- Add connectivity_distance column (distance to nearest segment in meters) 
ALTER TABLE eli_test.sites 
ADD COLUMN IF NOT EXISTS connectivity_distance FLOAT DEFAULT NULL;

-- Create index for performance on connectivity queries
CREATE INDEX IF NOT EXISTS idx_sites_connectivity_status 
ON eli_test.sites(connectivity_status);

-- Optional: Add comments to document the columns
COMMENT ON COLUMN eli_test.sites.connectivity_status IS 'Site connectivity status: connected/disconnected based on distance to network';
COMMENT ON COLUMN eli_test.sites.connectivity_distance IS 'Distance in meters to nearest network segment';