Fixes race condition in resources

This is accomplished by changing group_id, an integer field,
to group, a foreign key to a new model called ResourceGroup.