Fix the use of queries with a schema in a migration
authorrinpatch <rinpatch@sdf.org>
Sun, 6 Oct 2019 14:05:51 +0000 (17:05 +0300)
committerrinpatch <rinpatch@sdf.org>
Sun, 6 Oct 2019 14:23:43 +0000 (17:23 +0300)
priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs

index 50669902e57956be76b075c82b0d771bc6316152..815d665494746ca75e984240c70662f5005609d0 100644 (file)
@@ -1,15 +1,10 @@
 defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do
   use Ecto.Migration
+  import Ecto.Query
   alias Pleroma.User
 
   def change do
-    query =
-      User.Query.build(%{
-        local: true,
-        active: true,
-        order_by: :id
-      })
-
+    query = from(u in "users", where: fragment("not (?->'deactivated' @> 'true')", u.info), select: %{info: u.info}, where: u.local == true, order_by: u.id)
     Pleroma.Repo.stream(query)
     |> Enum.each(fn
       %{info: %{mutes: mutes} = info} = user ->