From d01d16f1ae60649929c6522dbfed73b255777048 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 31 May 2025 08:16:32 +0100 Subject: [PATCH] Add infrastructure to persist scrobble tracks to database Unused for now. --- lib/last_fm/track.ex | 4 ++-- .../20250530203701_create_scrobbled_tracks.exs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 priv/repo/migrations/20250530203701_create_scrobbled_tracks.exs diff --git a/lib/last_fm/track.ex b/lib/last_fm/track.ex index 4cccf2a7..c2033953 100644 --- a/lib/last_fm/track.ex +++ b/lib/last_fm/track.ex @@ -20,11 +20,11 @@ defmodule LastFm.Track do last_fm_data: map() } - embedded_schema do + @primary_key {:scrobbled_at_uts, :integer, autogenerate: false} + schema "scrobbled_tracks" do field :musicbrainz_id, :string field :title, :string field :cover_url, :string - field :scrobbled_at_uts, :integer field :scrobbled_at_label, :string embeds_one :artist, Artist diff --git a/priv/repo/migrations/20250530203701_create_scrobbled_tracks.exs b/priv/repo/migrations/20250530203701_create_scrobbled_tracks.exs new file mode 100644 index 00000000..9ac4d5b5 --- /dev/null +++ b/priv/repo/migrations/20250530203701_create_scrobbled_tracks.exs @@ -0,0 +1,16 @@ +defmodule MusicLibrary.Repo.Migrations.CreateScrobbledTracks do + use Ecto.Migration + + def change do + create table(:scrobbled_tracks, primary_key: false) do + add :scrobbled_at_uts, :integer, primary_key: true + add :musicbrainz_id, :string + add :title, :string + add :cover_url, :string + add :scrobbled_at_label, :string + add :artist, :map + add :album, :map + add :last_fm_data, :map + end + end +end