defmodule DaProductApp.Stores.Store do use Ecto.Schema import Ecto.Changeset schema "stores" do field :code, :string field :name, :string field :neo_merchant_id, :string, default: nil belongs_to :address, DaProductApp.Addresses.Address belongs_to :brand, DaProductApp.Brands.Brand timestamps() end def changeset(store, attrs) do store |> cast(attrs, [:code, :name, :address_id, :brand_id]) |> validate_required([:code, :name, :address_id, :brand_id]) end end