-- Add comprehensive fields to resources table based on Autotask Resources API
-- Reference: https://autotask.net/help/developerhelp/Content/APIs/REST/Entities/ResourcesEntity.htm

ALTER TABLE resources
  -- Name fields
  ADD COLUMN IF NOT EXISTS middle_initial VARCHAR(10),
  ADD COLUMN IF NOT EXISTS name_prefix VARCHAR(20),
  ADD COLUMN IF NOT EXISTS name_suffix VARCHAR(20),
  
  -- Contact information
  ADD COLUMN IF NOT EXISTS email_address VARCHAR(255),
  ADD COLUMN IF NOT EXISTS email_address2 VARCHAR(255),
  ADD COLUMN IF NOT EXISTS email_address3 VARCHAR(255),
  ADD COLUMN IF NOT EXISTS home_phone VARCHAR(50),
  
  -- Employment details
  ADD COLUMN IF NOT EXISTS accounting_reference_id VARCHAR(100),
  ADD COLUMN IF NOT EXISTS payroll_identifier VARCHAR(100),
  ADD COLUMN IF NOT EXISTS payroll_type INTEGER,
  ADD COLUMN IF NOT EXISTS internal_cost DECIMAL(15,2),
  
  -- Location and availability
  ADD COLUMN IF NOT EXISTS default_service_desk_role_id BIGINT,
  
  -- System fields
  ADD COLUMN IF NOT EXISTS email_type_code INTEGER,
  ADD COLUMN IF NOT EXISTS gender INTEGER,
  ADD COLUMN IF NOT EXISTS license_type INTEGER,
  ADD COLUMN IF NOT EXISTS number_format VARCHAR(50),
  ADD COLUMN IF NOT EXISTS time_format VARCHAR(50),
  ADD COLUMN IF NOT EXISTS date_format VARCHAR(50),
  
  -- Security
  ADD COLUMN IF NOT EXISTS security_level INTEGER;

-- Add comment to track migration
COMMENT ON TABLE resources IS 'Expanded with all Autotask API fields - Migration 015';
