Can fetch records by a specific artist

This commit is contained in:
Claudio Ortolina
2024-12-02 10:20:47 +00:00
parent 963b3c826f
commit b63b3a633a
4 changed files with 79 additions and 1 deletions
@@ -0,0 +1,18 @@
defmodule MusicLibrary.Repo.Migrations.CreateArtistRecordsView do
use Ecto.Migration
def up do
execute """
CREATE VIEW artist_records AS
SELECT json_extract(json_each.value, '$.musicbrainz_id') AS musicbrainz_id,
records.id AS record_id,
json_each.value as artist
FROM records,
json_each(records.artists)
"""
end
def down do
execute "DROP VIEW artist_records"
end
end