-- Add online status columns to clients table
-- Run this if you can't run migrations

-- For PostgreSQL (VPS)
ALTER TABLE clients ADD COLUMN IF NOT EXISTS is_online BOOLEAN DEFAULT FALSE;
ALTER TABLE clients ADD COLUMN IF NOT EXISTS last_seen TIMESTAMP NULL;

-- Create index for performance
CREATE INDEX IF NOT EXISTS idx_clients_is_online ON clients(is_online);
CREATE INDEX IF NOT EXISTS idx_clients_last_seen ON clients(last_seen);

-- Update existing records
UPDATE clients SET is_online = FALSE WHERE is_online IS NULL;

-- Verify columns were added
SELECT column_name, data_type, is_nullable, column_default 
FROM information_schema.columns 
WHERE table_name = 'clients' 
AND column_name IN ('is_online', 'last_seen');

