forked from shibao/cannery
- store ammo type grain as integer
- make ammo type desc as text
This commit is contained in:
parent
cc7162d267
commit
7015ec5997
@ -18,7 +18,7 @@ defmodule Cannery.Ammo.AmmoType do
|
|||||||
field :desc, :string
|
field :desc, :string
|
||||||
field :manufacturer, :string
|
field :manufacturer, :string
|
||||||
field :name, :string
|
field :name, :string
|
||||||
field :weight, :float
|
field :grain, :integer
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
@ -30,7 +30,7 @@ defmodule Cannery.Ammo.AmmoType do
|
|||||||
desc: String.t(),
|
desc: String.t(),
|
||||||
manufacturer: String.t(),
|
manufacturer: String.t(),
|
||||||
name: String.t(),
|
name: String.t(),
|
||||||
weight: float(),
|
grain: integer(),
|
||||||
inserted_at: NaiveDateTime.t(),
|
inserted_at: NaiveDateTime.t(),
|
||||||
updated_at: NaiveDateTime.t()
|
updated_at: NaiveDateTime.t()
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ defmodule Cannery.Ammo.AmmoType do
|
|||||||
@spec changeset(t() | new_ammo_type(), attrs :: map()) :: Changeset.t()
|
@spec changeset(t() | new_ammo_type(), attrs :: map()) :: Changeset.t()
|
||||||
def changeset(ammo_type, attrs) do
|
def changeset(ammo_type, attrs) do
|
||||||
ammo_type
|
ammo_type
|
||||||
|> cast(attrs, [:name, :desc, :case_material, :bullet_type, :weight, :manufacturer])
|
|> cast(attrs, [:name, :desc, :case_material, :bullet_type, :grain, :manufacturer])
|
||||||
|> validate_required([:name, :desc, :case_material, :bullet_type, :weight, :manufacturer])
|
|> validate_required([:name])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,10 +5,10 @@ defmodule Cannery.Repo.Migrations.CreateAmmoTypes do
|
|||||||
create table(:ammo_types, primary_key: false) do
|
create table(:ammo_types, primary_key: false) do
|
||||||
add :id, :binary_id, primary_key: true
|
add :id, :binary_id, primary_key: true
|
||||||
add :name, :string
|
add :name, :string
|
||||||
add :desc, :string
|
add :desc, :text
|
||||||
add :case_material, :string
|
add :case_material, :string
|
||||||
add :bullet_type, :string
|
add :bullet_type, :string
|
||||||
add :weight, :float
|
add :grain, :integer
|
||||||
add :manufacturer, :string
|
add :manufacturer, :string
|
||||||
|
|
||||||
timestamps()
|
timestamps()
|
||||||
|
Loading…
Reference in New Issue
Block a user