-- Fix database schema - Add missing columns to users table
ALTER TABLE users 
ADD COLUMN IF NOT EXISTS float_balance DECIMAL(10,2) DEFAULT 0.00,
ADD COLUMN IF NOT EXISTS house_edge_owed DECIMAL(10,2) DEFAULT 0.00,
ADD COLUMN IF NOT EXISTS is_active BOOLEAN DEFAULT TRUE,
ADD COLUMN IF NOT EXISTS last_assigned TIMESTAMP NULL;

-- Update existing agents with default float balance
UPDATE users SET float_balance = 50000.00 WHERE role = 'agent' AND float_balance = 0.00;

-- Create index for better performance
CREATE INDEX IF NOT EXISTS idx_users_role_active ON users(role, is_active);
