-- ================================================================ -- Migration 003: Add Email Verification Fields -- Version: v9c -- Date: 2026-03-21 -- ================================================================ -- Add email verification columns to profiles table ALTER TABLE profiles ADD COLUMN IF NOT EXISTS email_verified BOOLEAN DEFAULT FALSE, ADD COLUMN IF NOT EXISTS verification_token TEXT, ADD COLUMN IF NOT EXISTS verification_expires TIMESTAMP WITH TIME ZONE; -- Create index for verification token lookups CREATE INDEX IF NOT EXISTS idx_profiles_verification_token ON profiles(verification_token) WHERE verification_token IS NOT NULL; -- Mark existing users with email as verified (grandfather clause) UPDATE profiles SET email_verified = TRUE WHERE email IS NOT NULL AND email_verified IS NULL; COMMENT ON COLUMN profiles.email_verified IS 'Whether email address has been verified'; COMMENT ON COLUMN profiles.verification_token IS 'One-time token for email verification'; COMMENT ON COLUMN profiles.verification_expires IS 'Verification token expiry (24h from creation)';