I have here, for example, a user with many groups and the database is structured as follows:

```rb
class CreateGroups < ActiveRecord::Migration[6.0]
  def change
    create_table :groups, id: :uuid do |t|
      t.uuid    :user_id
      t.string  :name

      t.timestamps
    end

    add_index :groups, :name, unique: true
  end
end

```

The above will make `name` being unique across the entire database. I want `name` to be unique based on the user (`user_id`). Is that possible at database level? To have something like this, do I have to use [find or create](https://apidock.com/rails/ActiveRecord/Relation/first_or_create) instead?

If I have two users, they should be able to create the same group names but should not be the same for each user:

```rb
User.first.groups.first.name #> Bold
User.first.groups.second.name #> Bold (should fail)

User.second.groups.first.name #> Bold (should be ok)
User.second.groups.second.name #> Bold (should fail)

```