-- Extend reviews table to support admin-created reviews and admin moderation
ALTER TABLE reviews
  ALTER COLUMN lead_request_id DROP NOT NULL,
  ALTER COLUMN customer_id DROP NOT NULL,
  ALTER COLUMN professional_id DROP NOT NULL,
  ADD COLUMN IF NOT EXISTS title VARCHAR(255),
  ADD COLUMN IF NOT EXISTS subject_type VARCHAR(50) NOT NULL DEFAULT 'PLATFORM',
  ADD COLUMN IF NOT EXISTS subject_id VARCHAR(255),
  ADD COLUMN IF NOT EXISTS reviewer_name VARCHAR(255),
  ADD COLUMN IF NOT EXISTS status VARCHAR(20) NOT NULL DEFAULT 'PUBLISHED';

-- Sync status with is_published for existing rows
UPDATE reviews SET status = CASE WHEN is_published THEN 'PUBLISHED' ELSE 'HIDDEN' END;
