Fixed an issue with double foreign keys of the same type in the same model.