Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit bc6932f

Browse files
author
Chris Rees
committed
Add a user_games table
1 parent 50293f8 commit bc6932f

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/agoneum/account/user.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ defmodule Agoneum.Account.User do
1717

1818
field :admin, :boolean, default: false, null: false
1919

20+
many_to_many :games, Agoneum.Games.Game, join_through: "user_games"
21+
2022
timestamps()
2123
end
2224

lib/agoneum/games/game.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ defmodule Agoneum.Games.Game do
1717
field :name, :string
1818
field :year, :integer
1919

20+
many_to_many :users, Agoneum.Account.User, join_through: "user_games"
21+
2022
timestamps()
2123
end
2224

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
defmodule Agoneum.Repo.Migrations.AddUserGamesTable do
2+
use Ecto.Migration
3+
4+
def change do
5+
create table(:user_games, primary_key: false) do
6+
add :user_id, references(:users)
7+
add :game_id, references(:games)
8+
end
9+
end
10+
end

0 commit comments

Comments
 (0)