-- Migration: Add fingerprint support to accounts table
-- This migration adds fingerprint_id column to accounts table

-- Add fingerprint_id column to accounts table if it doesn't exist
ALTER TABLE accounts ADD COLUMN fingerprint_id TEXT;

-- Add session_id column to accounts table if it doesn't exist
ALTER TABLE accounts ADD COLUMN session_id TEXT;

-- Add last_session_update column to track session health
ALTER TABLE accounts ADD COLUMN last_session_update TEXT;

-- Create index for faster lookups
CREATE INDEX IF NOT EXISTS idx_accounts_fingerprint ON accounts(fingerprint_id);
CREATE INDEX IF NOT EXISTS idx_accounts_session ON accounts(session_id);

-- Update existing accounts to have NULL fingerprint_id (will be generated on login)
UPDATE accounts SET fingerprint_id = NULL WHERE fingerprint_id IS NULL;