add seeding of db
This commit is contained in:
parent
176707ed4b
commit
68462b7cb7
4
mix.exs
4
mix.exs
|
@ -47,7 +47,9 @@ defmodule PokemonCouture.MixProject do
|
||||||
{:jason, "~> 1.0"},
|
{:jason, "~> 1.0"},
|
||||||
{:plug_cowboy, "~> 2.0"},
|
{:plug_cowboy, "~> 2.0"},
|
||||||
|
|
||||||
{:phx_gen_auth, "~> 0.7", only: [:dev], runtime: false}
|
{:phx_gen_auth, "~> 0.7", only: [:dev], runtime: false},
|
||||||
|
{:csv, "~> 2.4.1"}
|
||||||
|
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,5 +12,15 @@
|
||||||
|
|
||||||
alias PokemonCouture.Repo
|
alias PokemonCouture.Repo
|
||||||
alias PokemonCouture.Shops.Clothes
|
alias PokemonCouture.Shops.Clothes
|
||||||
|
defmodule Parser do
|
||||||
|
def parse do
|
||||||
|
File.stream!("sunmoon_clothes.csv")
|
||||||
|
|> CSV.decode!(headers: :true)
|
||||||
|
# |> Enum.each(fn x -> IO.inspect(x) end)
|
||||||
|
|> Enum.map(fn x -> %Clothes{game: x["game"], location: x["location"], name: x["name"], color: x["color"]} end)
|
||||||
|
|> Enum.each(fn x -> Repo.insert!(x) end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Repo.insert! %Clothes{game: "Tlapka", location: "Tlapkov", name: "Tlapka Hat", color: "Blue"}
|
Repo.insert! %Clothes{game: "Tlapka", location: "Tlapkov", name: "Tlapka Hat", color: "Blue"}
|
||||||
|
Parser.parse()
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
name,color,location,game
|
||||||
|
Designer Top,White,Gracidea,Both
|
||||||
|
Designer Top,Black,Gracidea,Both
|
||||||
|
Designer Top,Red,Gracidea,Sun
|
||||||
|
Designer Top,Green,Gracidea,Moon
|
||||||
|
Designer Top,Yellow,Gracidea,Sun
|
||||||
|
Designer Top,Blue,Gracidea,Moon
|
||||||
|
Designer Top,Orange,Gracidea,Sun
|
||||||
|
Designer Top,Navy,Gracidea,Moon
|
||||||
|
Designer Top,Pink,Gracidea,Sun
|
||||||
|
Designer Top,Purple,Gracidea,Moon
|
||||||
|
Designer Top,Beige,Gracidea,Sun
|
||||||
|
Designer Top,Gray,Gracidea,Moon
|
||||||
|
Strappy Sandals,White,Gracidea,Both
|
||||||
|
Strappy Sandals,Black,Gracidea,Both
|
||||||
|
Strappy Sandals,Red,Gracidea,Sun
|
||||||
|
Strappy Sandals,Green,Gracidea,Moon
|
||||||
|
Strappy Sandals,Yellow,Gracidea,Sun
|
||||||
|
Strappy Sandals,Blue,Gracidea,Moon
|
||||||
|
Strappy Sandals,Orange,Gracidea,Sun
|
||||||
|
Strappy Sandals,Navy,Gracidea,Moon
|
||||||
|
Strappy Sandals,Pink,Gracidea,Sun
|
||||||
|
Strappy Sandals,Purple,Gracidea,Moon
|
||||||
|
Strappy Sandals,Beige,Gracidea,Sun
|
||||||
|
Strappy Sandals,Gray,Gracidea,Moon
|
||||||
|
Satchel Bag,White,Gracidea,Both
|
||||||
|
Satchel Bag,Black,Gracidea,Both
|
||||||
|
Satchel Bag,Red,Gracidea,Sun
|
||||||
|
Satchel Bag,Green,Gracidea,Moon
|
||||||
|
Satchel Bag,Yellow,Gracidea,Sun
|
||||||
|
Satchel Bag,Blue,Gracidea,Moon
|
||||||
|
Satchel Bag,Orange,Gracidea,Sun
|
||||||
|
Satchel Bag,Navy,Gracidea,Moon
|
||||||
|
Satchel Bag,Pink,Gracidea,Sun
|
||||||
|
Satchel Bag,Purple,Gracidea,Moon
|
||||||
|
Satchel Bag,Beige,Gracidea,Sun
|
||||||
|
Satchel Bag,Gray,Gracidea,Moon
|
||||||
|
Beach Hat,White,Gracidea,Both
|
||||||
|
Beach Hat,Black,Gracidea,Both
|
||||||
|
Beach Hat,Red,Gracidea,Sun
|
||||||
|
Beach Hat,Green,Gracidea,Moon
|
||||||
|
Beach Hat,Yellow,Gracidea,Sun
|
||||||
|
Beach Hat,Blue,Gracidea,Moon
|
||||||
|
Beach Hat,Orange,Gracidea,Sun
|
||||||
|
Beach Hat,Navy,Gracidea,Moon
|
||||||
|
Beach Hat,Pink,Gracidea,Sun
|
||||||
|
Beach Hat,Purple,Gracidea,Moon
|
||||||
|
Beach Hat,Beige,Gracidea,Sun
|
||||||
|
Beach Hat,Gray,Gracidea,Moon
|
||||||
|
Oversized Sunglasses,Gray,Gracidea,Moon
|
||||||
|
Oversized Sunglasses,Blue,Gracidea,Moon
|
||||||
|
Oversized Sunglasses,Purple,Gracidea,Moon
|
||||||
|
Gem Barrette,White,Gracidea,Moon
|
||||||
|
Gem Barrette,Blue,Gracidea,Moon
|
|
Loading…
Reference in New Issue