diff --git a/lib/pento_web/router.ex b/lib/pento_web/router.ex index c07dd22..7d2e4c9 100644 --- a/lib/pento_web/router.ex +++ b/lib/pento_web/router.ex @@ -26,7 +26,13 @@ defmodule PentoWeb.Router do get "/", PageController, :home live "/guess", WrongLive - resources "/products", ProductController + + live "/products", ProductLive.Index, :index + live "/products/new", ProductLive.Index, :new + live "/products/:id/edit", ProductLive.Index, :edit + + live "/products/:id", ProductLive.Show, :show + live "/products/:id/show/edit", ProductLive.Show, :edit end # Other scopes may use custom stacks. diff --git a/priv/repo/migrations/20240210162636_create_products.exs b/priv/repo/migrations/20240210162636_create_products.exs new file mode 100644 index 0000000..22f9488 --- /dev/null +++ b/priv/repo/migrations/20240210162636_create_products.exs @@ -0,0 +1,16 @@ +defmodule Pento.Repo.Migrations.CreateProducts do + use Ecto.Migration + + def change do + create table(:products) do + add :name, :string + add :description, :string + add :unit_price, :float + add :sku, :integer + + timestamps(type: :utc_datetime) + end + + create unique_index(:products, [:sku]) + end +end