-- Migration: Add tokenVersion field to users table
-- This enables token invalidation when new tokens are generated

ALTER TABLE users 
ADD COLUMN tokenVersion INT DEFAULT 0 NOT NULL AFTER fcmTokens;

-- Add index for faster token validation
CREATE INDEX idx_token_version ON users(id, tokenVersion);

-- Update existing users to have tokenVersion = 0
UPDATE users SET tokenVersion = 0 WHERE tokenVersion IS NULL;
