First
[anni] / priv / repo / migrations / 20200527163635_delete_notifications_from_invisible_users.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Repo.Migrations.DeleteNotificationsFromInvisibleUsers do
6   use Ecto.Migration
7
8   import Ecto.Query
9   alias Pleroma.Repo
10
11   def up do
12     Pleroma.Notification
13     |> join(:inner, [n], activity in assoc(n, :activity))
14     |> where(
15       [n, a],
16       fragment("? in (SELECT ap_id FROM users WHERE invisible = true)", a.actor)
17     )
18     |> Repo.delete_all()
19   end
20
21   def down, do: :ok
22 end