Generate schema and live_view scaffold for records

1. Records are not yet tied to artists
2. The generated edit route, along with related functionality, may be
   deleted as I don't think it's gonna be needed. Leaving it included in
   the commit for reference.
This commit is contained in:
Claudio Ortolina
2024-09-12 14:42:15 +01:00
parent 34111a44ba
commit e08fbe3740
12 changed files with 603 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
defmodule MusicLibrary.Records.Record do
use Ecto.Schema
import Ecto.Changeset
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "records" do
field :type, Ecto.Enum, values: [:album, :ep, :live, :compilation, :single, :other]
field :title, :string
field :image, :string
field :year, :integer
field :musicbrainz_id, Ecto.UUID
field :genres, {:array, :string}
timestamps(type: :utc_datetime)
end
@doc false
def changeset(record, attrs) do
record
|> cast(attrs, [:type, :title, :musicbrainz_id, :year, :genres, :image])
|> validate_required([:type, :title, :musicbrainz_id, :year, :genres, :image])
end
end