-- Debug organization issue
-- Check user 37 and organization data

-- 1. Check user 37's current organization
SELECT 'User 37 Details:' as info, id, full_name, email, role, organization_id, is_active
FROM users 
WHERE id = 37;

-- 2. Check all organizations
SELECT 'All Organizations:' as info, id, name, status, created_at
FROM organizations
ORDER BY id;

-- 3. Check users in organization 11 (where JWT says user should be)
SELECT 'Users in Organization 11:' as info, id, full_name, email, role, is_active
FROM users 
WHERE organization_id = 11
ORDER BY full_name;

-- 4. Check users in organization 1 (where DB says user currently is)
SELECT 'Users in Organization 1:' as info, id, full_name, email, role, is_active
FROM users 
WHERE organization_id = 1
ORDER BY full_name;

-- 5. Check if there are duplicate Server users
SELECT 'All Server users:' as info, id, full_name, email, organization_id, is_active
FROM users
WHERE email LIKE '%server%' OR full_name LIKE '%Server%'
ORDER BY id;