diff options
author | rinpatch <rinpatch@sdf.org> | 2020-05-11 22:13:08 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-05-11 22:13:08 +0000 |
commit | 2ead4e108a802e73aea34e506a4f9f50eb0b3993 (patch) | |
tree | ad79c2f56bb40afdf824504027e22cb881fc9445 | |
parent | 9b33cab06ee99f357b0df8512e92136b5f1433a1 (diff) | |
parent | f6aa0b4a0792e7c69af6e7008a2ba354ca26adf4 (diff) | |
download | pleroma-2ead4e108a802e73aea34e506a4f9f50eb0b3993.tar.gz pleroma-2ead4e108a802e73aea34e506a4f9f50eb0b3993.zip |
Merge branch 'migration-fix-markers' into 'develop'
Markers migration: Fix migration for very large list of markers
See merge request pleroma/pleroma!2511
-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..bb9d8e860 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_every(1000) + |> Enum.each(fn markers_attrs_chunked -> + Repo.insert_all("markers", markers_attrs_chunked, + on_conflict: {:replace, [:last_read_id]}, + conflict_target: [:user_id, :timeline] + ) + end) end end |