-- Add user notes fields to company_intel table
ALTER TABLE company_intel
ADD COLUMN IF NOT EXISTS user_notes TEXT,
ADD COLUMN IF NOT EXISTS manually_updated BOOLEAN DEFAULT false,
ADD COLUMN IF NOT EXISTS updated_by VARCHAR(255),
ADD COLUMN IF NOT EXISTS notes_updated_at TIMESTAMP WITH TIME ZONE;

-- Add user notes fields to lead_intel table
ALTER TABLE lead_intel
ADD COLUMN IF NOT EXISTS user_notes TEXT,
ADD COLUMN IF NOT EXISTS manually_updated BOOLEAN DEFAULT false,
ADD COLUMN IF NOT EXISTS updated_by VARCHAR(255),
ADD COLUMN IF NOT EXISTS notes_updated_at TIMESTAMP WITH TIME ZONE;

-- Create index for faster queries
CREATE INDEX IF NOT EXISTS idx_company_intel_user_notes ON company_intel(manually_updated) WHERE manually_updated = true;
CREATE INDEX IF NOT EXISTS idx_lead_intel_user_notes ON lead_intel(manually_updated) WHERE manually_updated = true;
