I thought we settled on global teams not being user-owned. There's no benefit to a global team being user-owned if they cannot manage the membership, and several downsides (admin script can fail if the owning user already has a team with the same name, admin script has to pick an owner, global teams would inherit the owner as a member, which is weird for LDAP-backed groups, etc). Remove the global flag, and change the conditions that filter on global:true/false to filter on owner_id:nil/non-nil. You then get uniqueness of global team names for free with the existing index.