-- Verify admin user has super_admin role
SELECT u.id, u.username, u.email, r.role_name, r.role_code
FROM users u
LEFT JOIN user_roles ur ON u.id = ur.user_id
LEFT JOIN roles r ON ur.role_id = r.id
WHERE u.username = 'admin';

-- If admin doesn't have super_admin role, add it
INSERT INTO user_roles (user_id, role_id)
SELECT u.id, r.id
FROM users u, roles r
WHERE u.username = 'admin' 
AND r.role_code = 'super_admin'
AND NOT EXISTS (
    SELECT 1 FROM user_roles ur2
    WHERE ur2.user_id = u.id AND ur2.role_id = r.id
);

-- Verify the fix
SELECT u.id, u.username, u.email, r.role_name, r.role_code
FROM users u
LEFT JOIN user_roles ur ON u.id = ur.user_id
LEFT JOIN roles r ON ur.role_id = r.id
WHERE u.username = 'admin';

-- Check sample data exists
SELECT COUNT(*) as sample_count FROM samples;
SELECT * FROM samples LIMIT 3;
