Merge branch 'bugfix/mastofe-install-script' into 'develop'
[akkoma] / lib / mix / tasks / pleroma / database.ex
index a01c36ece30754ada443c22dffc5e3d29b9f73cf..22151ce08e4d6fef4c42c23f04490d15837656d3 100644 (file)
@@ -48,9 +48,15 @@ defmodule Mix.Tasks.Pleroma.Database do
   def run(["update_users_following_followers_counts"]) do
     start_pleroma()
 
-    User
-    |> Repo.all()
-    |> Enum.each(&User.update_follower_count/1)
+    Repo.transaction(
+      fn ->
+        from(u in User, select: u)
+        |> Repo.stream()
+        |> Stream.each(&User.update_follower_count/1)
+        |> Stream.run()
+      end,
+      timeout: :infinity
+    )
   end
 
   def run(["prune_objects" | args]) do