Add batch function to remove artist IDs
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user