1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Repo.Migrations.DeleteNotificationWithoutActivity do
13 q in Pleroma.Notification,
14 left_join: c in assoc(q, :activity),
15 select: %{id: type(q.id, :integer)},
18 |> Repo.chunk_stream(1_000, :batches)
19 |> Stream.each(fn records ->
20 notification_ids = Enum.map(records, fn %{id: id} -> id end)
23 from(n in "notifications",
24 where: n.id in ^notification_ids