|> unique_constraint(:product_id, name: :index_ratings_on_user_product)
should be:
|> unique_constraint([:user_id, :product_id], name: :index_ratings_on_user_product)
|> unique_constraint(:product_id, name: :index_ratings_on_user_product)
should be:
|> unique_constraint([:user_id, :product_id], name: :index_ratings_on_user_product)
Nevermind, I read the docs and understand only the name of the index matters in this situation.