25 lines
700 B
Elixir
25 lines
700 B
Elixir
defmodule BeetRoundServer.Biddings.Bidding do
|
|
use Ecto.Schema
|
|
import Ecto.Changeset
|
|
|
|
@primary_key {:id, :binary_id, autogenerate: true}
|
|
@foreign_key_type :binary_id
|
|
schema "biddings" do
|
|
field :bidding_round, :integer
|
|
field :amount, :integer
|
|
field :depot_wish_one, :string
|
|
field :depot_wish_two, :string
|
|
field :user_id, :binary_id
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
@doc false
|
|
def changeset(bidding, attrs, user_scope) do
|
|
bidding
|
|
|> cast(attrs, [:bidding_round, :amount, :depot_wish_one, :depot_wish_two])
|
|
|> validate_required([:bidding_round, :amount, :depot_wish_one, :depot_wish_two])
|
|
|> put_change(:user_id, user_scope.user.id)
|
|
end
|
|
end
|