diff --git a/lib/music_library/records/batch.ex b/lib/music_library/records/batch.ex index 4bc5e8f6..de58ecd7 100644 --- a/lib/music_library/records/batch.ex +++ b/lib/music_library/records/batch.ex @@ -52,6 +52,13 @@ defmodule MusicLibrary.Records.Batch do |> Repo.update() end + def remove_artists_ids! do + # Shotgun approach: remove the first 4 artists IDs from each record. + # This is not a general solution, but it works as a quick fix because the record with the most artists has 3. + q = "update records set artists = json_remove(artists, '$[0].id', '$[1].id', '$[2].id', '$[3].id');" + Repo.query(q) + end + defp run_on_all_records(fun) do q = from(r in Record) stream = Repo.stream(q, max_rows: 50)