projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
768c18f
)
Markers migration: Fix migration for very large list of markers
author
lain
<lain@soykaf.club>
Mon, 11 May 2020 19:52:47 +0000
(21:52 +0200)
committer
lain
<lain@soykaf.club>
Mon, 11 May 2020 19:52:47 +0000
(21:52 +0200)
priv/repo/migrations/20200415181818_update_markers.exs
patch
|
blob
|
history
diff --git
a/priv/repo/migrations/20200415181818_update_markers.exs
b/priv/repo/migrations/20200415181818_update_markers.exs
index 976363565315478f6ce88493a72c0262ecb8c7b4..b7c611333020ba13a06624524e1bda7b37048c70 100644
(file)
--- 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