-- Migration: Add email verification columns to users table -- Run this migration on the punimtag_auth database -- Add email_verified column (defaults to false for new users, true for existing users) ALTER TABLE users ADD COLUMN IF NOT EXISTS email_verified BOOLEAN NOT NULL DEFAULT true; -- Add email_confirmation_token column ALTER TABLE users ADD COLUMN IF NOT EXISTS email_confirmation_token VARCHAR(255) UNIQUE; -- Add email_confirmation_token_expiry column ALTER TABLE users ADD COLUMN IF NOT EXISTS email_confirmation_token_expiry TIMESTAMP; -- Create index on email_confirmation_token for faster lookups CREATE INDEX IF NOT EXISTS idx_users_email_confirmation_token ON users(email_confirmation_token); -- Update existing users to have verified emails (for backward compatibility) -- Only update users that don't have the token set (meaning they were created before this migration) UPDATE users SET email_verified = true WHERE email_confirmation_token IS NULL;