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
|
||||
|
||||
schema "clothes" do
|
||||
field :name, :string
|
||||
field :color, :string
|
||||
field :game, :string
|
||||
field :location, :string
|
||||
field :name, :string
|
||||
|
||||
many_to_many :users, PokemonCouture.Accounts.User, join_through: "ownerships", unique: :true
|
||||
|
||||
timestamps()
|
||||
|
@ -14,7 +16,7 @@ defmodule PokemonCouture.Shops.Clothes do
|
|||
@doc false
|
||||
def changeset(clothes, attrs) do
|
||||
clothes
|
||||
|> cast(attrs, [:name, :location, :game])
|
||||
|> validate_required([:name, :location, :game])
|
||||
|> cast(attrs, [:name, :location, :game, :color])
|
||||
|> validate_required([:name, :location, :game, :color])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,9 +4,9 @@ defmodule PokemonCouture.Repo.Migrations.CreateClothes do
|
|||
def change do
|
||||
create table(:clothes) do
|
||||
add :name, :string
|
||||
add :color, :string
|
||||
add :location, :string
|
||||
add :game, :string
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
|
|
|
@ -9,3 +9,8 @@
|
|||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# 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