Generate basic artist schema
This commit is contained in:
@@ -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
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
defmodule MusicLibrary.Repo.Migrations.CreateArtists do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
create table(:artists, primary_key: false) do
|
||||||
|
add :id, :binary_id, primary_key: true
|
||||||
|
add :name, :string
|
||||||
|
add :musicbrainz_id, :uuid
|
||||||
|
add :image, :string
|
||||||
|
|
||||||
|
timestamps(type: :utc_datetime)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user