- store ammo type grain as integer

- make ammo type desc as text
This commit is contained in:
shibao 2022-01-31 22:29:09 -05:00
parent cc7162d267
commit 7015ec5997
2 changed files with 6 additions and 6 deletions

View File

@ -18,7 +18,7 @@ defmodule Cannery.Ammo.AmmoType do
field :desc, :string
field :manufacturer, :string
field :name, :string
field :weight, :float
field :grain, :integer
timestamps()
end
@ -30,7 +30,7 @@ defmodule Cannery.Ammo.AmmoType do
desc: String.t(),
manufacturer: String.t(),
name: String.t(),
weight: float(),
grain: integer(),
inserted_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()
def changeset(ammo_type, attrs) do
ammo_type
|> cast(attrs, [:name, :desc, :case_material, :bullet_type, :weight, :manufacturer])
|> validate_required([:name, :desc, :case_material, :bullet_type, :weight, :manufacturer])
|> cast(attrs, [:name, :desc, :case_material, :bullet_type, :grain, :manufacturer])
|> validate_required([:name])
end
end

View File

@ -5,10 +5,10 @@ defmodule Cannery.Repo.Migrations.CreateAmmoTypes do
create table(:ammo_types, primary_key: false) do
add :id, :binary_id, primary_key: true
add :name, :string
add :desc, :string
add :desc, :text
add :case_material, :string
add :bullet_type, :string
add :weight, :float
add :grain, :integer
add :manufacturer, :string
timestamps()