add shops context, clothes and users-clothes

users-clothes is a many-to-many unique relationship
This commit is contained in:
2021-06-28 16:32:25 +02:00
parent 28823a6972
commit 4f8b87a2d9
14 changed files with 454 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
defmodule PokemonCouture.Shops.Clothes do
use Ecto.Schema
import Ecto.Changeset
schema "clothes" do
field :game, :string
field :location, :string
field :name, :string
many_to_many :users, PokemonCouture.Accounts.User, join_through: "ownerships", unique: :true
timestamps()
end
@doc false
def changeset(clothes, attrs) do
clothes
|> cast(attrs, [:name, :location, :game])
|> validate_required([:name, :location, :game])
end
end