This is an old question and the previously accepted answer was no longer the de facto way.
Ecto now supports HABTM or many to many associations.
https://hexdocs.pm/ecto/Ecto.Schema.html#many_to_many/3
many_to_many :users, MyApp.User, join_through: "chat_group_users"