-- ============================================================================
-- Clean Up User from Supabase Auth Completely
-- ============================================================================

-- NOTE: You CANNOT just DELETE from auth.users
-- Supabase keeps deleted users in a recycle bin

-- To completely remove a user, you need to use Supabase Auth Admin API
-- OR use a cascade delete from a linked table

-- Option 1: Delete via cascade (if you have foreign keys)
-- This works because auth_otps has ON DELETE CASCADE
DELETE FROM auth.users WHERE email = 'your@email.com';

-- Option 2: Check if user still exists in recycle bin
SELECT id, email, deleted_at
FROM auth.users
WHERE email = 'your@email.com';

-- If you see deleted_at IS NOT NULL, the user is in recycle bin

-- To permanently delete from recycle bin, you need to:
-- 1. Go to Supabase Dashboard → Authentication → Users
-- 2. Find the user
-- 3. Click "Permanently delete"

-- OR use the Auth Admin API from an edge function:
/*
const { data, error } = await supabase.auth.admin.deleteUser(userId);
*/
