Issue:
When a team gets deleted team_id is not properly cleared from users who
have set the team to be deleted as their main. When now someone trys
an operation that validates the user it fails as the team_id set on that
user is not valid anymore.
Solution:
To prevent this from happening in the future update users and set
team_id to nil.
Clean up:
To clean up existing users run
UPDATE users SET team_id=NULL WHERE team_id NOT IN(SELECT id FROM
teams);