remove tag_id from ammo group

This commit is contained in:
shibao 2022-02-09 23:45:10 -05:00
parent aa17240c83
commit bb4e6954eb
2 changed files with 6 additions and 11 deletions

View File

@ -9,7 +9,7 @@ defmodule Cannery.Ammo.AmmoGroup do
use Ecto.Schema use Ecto.Schema
import Ecto.Changeset import Ecto.Changeset
alias Cannery.Ammo.{AmmoGroup, AmmoType} alias Cannery.Ammo.{AmmoGroup, AmmoType}
alias Cannery.{Accounts.User, Containers.Container, Tags.Tag} alias Cannery.{Accounts.User, Containers.Container}
alias Ecto.{Changeset, UUID} alias Ecto.{Changeset, UUID}
@primary_key {:id, :binary_id, autogenerate: true} @primary_key {:id, :binary_id, autogenerate: true}
@ -19,7 +19,6 @@ defmodule Cannery.Ammo.AmmoGroup do
field :notes, :string field :notes, :string
field :price_paid, :float field :price_paid, :float
belongs_to :tag, Tag
belongs_to :ammo_type, AmmoType belongs_to :ammo_type, AmmoType
belongs_to :container, Container belongs_to :container, Container
belongs_to :user, User belongs_to :user, User
@ -30,15 +29,13 @@ defmodule Cannery.Ammo.AmmoGroup do
@type t :: %AmmoGroup{ @type t :: %AmmoGroup{
id: id(), id: id(),
count: integer, count: integer,
notes: String.t(), notes: String.t() | nil,
price_paid: float(), price_paid: float() | nil,
tag: Tag.t(), ammo_type: AmmoType.t() | nil,
tag_id: Tag.id(),
ammo_type: AmmoType.t(),
ammo_type_id: AmmoType.id(), ammo_type_id: AmmoType.id(),
container: Container.t(), container: Container.t() | nil,
container_id: Container.id(), container_id: Container.id(),
user: User.t(), user: User.t() | nil,
user_id: User.id(), user_id: User.id(),
inserted_at: NaiveDateTime.t(), inserted_at: NaiveDateTime.t(),
updated_at: NaiveDateTime.t() updated_at: NaiveDateTime.t()

View File

@ -8,7 +8,6 @@ defmodule Cannery.Repo.Migrations.CreateAmmoGroups do
add :price_paid, :float add :price_paid, :float
add :notes, :text add :notes, :text
add :tag_id, references(:tags, on_delete: :nothing, type: :binary_id)
add :ammo_type_id, references(:ammo_types, on_delete: :delete_all, type: :binary_id) add :ammo_type_id, references(:ammo_types, on_delete: :delete_all, type: :binary_id)
add :container_id, references(:containers, on_delete: :nothing, type: :binary_id) add :container_id, references(:containers, on_delete: :nothing, type: :binary_id)
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id) add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
@ -16,7 +15,6 @@ defmodule Cannery.Repo.Migrations.CreateAmmoGroups do
timestamps() timestamps()
end end
create index(:ammo_groups, [:tag_id])
create index(:ammo_groups, [:ammo_type_id]) create index(:ammo_groups, [:ammo_type_id])
create index(:ammo_groups, [:container_id]) create index(:ammo_groups, [:container_id])
create index(:ammo_groups, [:user_id]) create index(:ammo_groups, [:user_id])