index

Defining a Unique Field Using Migrations

I've seen this come up quite a few times so it warrants a permanent reference here:

How its done

In your migraton put:

add_index :permissions_roles, [:permission_id, :role_id], 'unique'

If you're using it as a key make it an index as well

add_index :permissions_roles, [:permission_id, :role_id], 'unique', :index => true