```ruby
class UserIdentity < ActiveRecord::Base
  belongs_to :user
  validates :provider, uniqueness: { scope: :user_id }
end
```

Add validation for uid uniqness
user
```ruby
class UserIdentity < ActiveRecord::Base
  belongs_to :user
  validates :provider, uniqueness: { scope: :user_id }
  validates :uid, uniqueness: { scope: :provider }
end
```
assistant