Fix creation of usergroups

We need to specify :inverse_of if we want to validate associations. Also
I added missing foreign keys and missing dependency between auth sources
and external usergroups.