-- Fix duplicate agent records
DELETE u1 FROM users u1
INNER JOIN users u2 
WHERE u1.id > u2.id 
AND u1.username = u2.username 
AND u1.role = 'agent';

-- Ensure unique usernames
ALTER TABLE users ADD CONSTRAINT unique_username UNIQUE (username);
