diff options
author | lain <lain@soykaf.club> | 2020-05-11 21:52:47 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-11 21:52:47 +0200 |
commit | d8dd945a0319692b05370f16f289d8a231217ee6 (patch) | |
tree | 1d7a3159bf99f29a07c9f96a5be5a87831f18892 | |
parent | 768c18facb28b3ebff5719e70e6d094c3b29c871 (diff) | |
download | pleroma-d8dd945a0319692b05370f16f289d8a231217ee6.tar.gz |
Markers migration: Fix migration for very large list of markers
-rw-r--r-- | priv/repo/migrations/20200415181818_update_markers.exs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/priv/repo/migrations/20200415181818_update_markers.exs b/priv/repo/migrations/20200415181818_update_markers.exs index 976363565..b7c611333 100644 --- a/priv/repo/migrations/20200415181818_update_markers.exs +++ b/priv/repo/migrations/20200415181818_update_markers.exs @@ -32,9 +32,13 @@ defmodule Pleroma.Repo.Migrations.UpdateMarkers do |> Map.put_new(:updated_at, now) end) - Repo.insert_all("markers", markers_attrs, - on_conflict: {:replace, [:last_read_id]}, - conflict_target: [:user_id, :timeline] - ) + markers_attrs + |> Enum.chunk(1000) + |> Enum.each(fn marker_attrs -> + Repo.insert_all("markers", markers_attrs, + on_conflict: {:replace, [:last_read_id]}, + conflict_target: [:user_id, :timeline] + ) + end) end end |