add color to clothes
This commit is contained in:
parent
4f8b87a2d9
commit
176707ed4b
|
@ -3,9 +3,11 @@ defmodule PokemonCouture.Shops.Clothes do
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
|
|
||||||
schema "clothes" do
|
schema "clothes" do
|
||||||
|
field :name, :string
|
||||||
|
field :color, :string
|
||||||
field :game, :string
|
field :game, :string
|
||||||
field :location, :string
|
field :location, :string
|
||||||
field :name, :string
|
|
||||||
many_to_many :users, PokemonCouture.Accounts.User, join_through: "ownerships", unique: :true
|
many_to_many :users, PokemonCouture.Accounts.User, join_through: "ownerships", unique: :true
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
|
@ -14,7 +16,7 @@ defmodule PokemonCouture.Shops.Clothes do
|
||||||
@doc false
|
@doc false
|
||||||
def changeset(clothes, attrs) do
|
def changeset(clothes, attrs) do
|
||||||
clothes
|
clothes
|
||||||
|> cast(attrs, [:name, :location, :game])
|
|> cast(attrs, [:name, :location, :game, :color])
|
||||||
|> validate_required([:name, :location, :game])
|
|> validate_required([:name, :location, :game, :color])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,9 +4,9 @@ defmodule PokemonCouture.Repo.Migrations.CreateClothes do
|
||||||
def change do
|
def change do
|
||||||
create table(:clothes) do
|
create table(:clothes) do
|
||||||
add :name, :string
|
add :name, :string
|
||||||
|
add :color, :string
|
||||||
add :location, :string
|
add :location, :string
|
||||||
add :game, :string
|
add :game, :string
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,3 +9,8 @@
|
||||||
#
|
#
|
||||||
# We recommend using the bang functions (`insert!`, `update!`
|
# We recommend using the bang functions (`insert!`, `update!`
|
||||||
# and so on) as they will fail if something goes wrong.
|
# and so on) as they will fail if something goes wrong.
|
||||||
|
|
||||||
|
alias PokemonCouture.Repo
|
||||||
|
alias PokemonCouture.Shops.Clothes
|
||||||
|
|
||||||
|
Repo.insert! %Clothes{game: "Tlapka", location: "Tlapkov", name: "Tlapka Hat", color: "Blue"}
|
||||||
|
|
Loading…
Reference in New Issue