-- Migration: 003_add_email_verified_and_onboarding
-- Description: Add email verification status and onboarding tracking columns
-- Date: 2025-12-22

-- Add email verification status column
ALTER TABLE user_profiles
  ADD COLUMN IF NOT EXISTS email_verified BOOLEAN NOT NULL DEFAULT false;

-- Add onboarding completion timestamp column
ALTER TABLE user_profiles
  ADD COLUMN IF NOT EXISTS onboarding_completed_at TIMESTAMP WITH TIME ZONE DEFAULT NULL;

-- Create index for efficient email verification status queries
CREATE INDEX IF NOT EXISTS idx_user_profiles_email_verified
  ON user_profiles(email_verified);

-- Create index for onboarding status queries
CREATE INDEX IF NOT EXISTS idx_user_profiles_onboarding_completed
  ON user_profiles(onboarding_completed_at);

-- Add comment for documentation
COMMENT ON COLUMN user_profiles.email_verified IS 'Whether the user has verified their email address via Auth0';
COMMENT ON COLUMN user_profiles.onboarding_completed_at IS 'Timestamp when user completed the onboarding flow, NULL if not completed';
