Generate basic artist schema

This commit is contained in:
Claudio Ortolina
2024-09-12 14:33:57 +01:00
parent 8255e50e1d
commit 34111a44ba
2 changed files with 35 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
defmodule MusicLibrary.Records.Artist do
use Ecto.Schema
import Ecto.Changeset
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "artists" do
field :name, :string
field :image, :string
field :musicbrainz_id, Ecto.UUID
timestamps(type: :utc_datetime)
end
@doc false
def changeset(artist, attrs) do
artist
|> cast(attrs, [:name, :musicbrainz_id, :image])
|> validate_required([:name, :musicbrainz_id, :image])
end
end