-- Add email verification columns to users table
-- Run this migration if you get error: Column 'email_verified' not found

ALTER TABLE `users` 
ADD COLUMN `email_verified` TINYINT(1) NOT NULL DEFAULT 0 AFTER `email`,
ADD COLUMN `email_verification_token` VARCHAR(64) NULL DEFAULT NULL AFTER `email_verified`,
ADD COLUMN `email_verification_sent_at` DATETIME NULL DEFAULT NULL AFTER `email_verification_token`;

-- Add index for faster token lookups
ALTER TABLE `users`
ADD INDEX `idx_email_verification_token` (`email_verification_token`);

-- Note: Existing users will have email_verified = 0 (unverified)
-- You may want to manually set email_verified = 1 for existing users:
-- UPDATE users SET email_verified = 1 WHERE email_verified = 0;
