Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

31 líneas
638B

  1. defmodule Pleroma.Repo.Migrations.DeleteNotificationWithoutActivity do
  2. use Ecto.Migration
  3. import Ecto.Query
  4. alias Pleroma.Repo
  5. def up do
  6. from(
  7. q in Pleroma.Notification,
  8. left_join: c in assoc(q, :activity),
  9. select: %{id: type(q.id, :integer)},
  10. where: is_nil(c.id)
  11. )
  12. |> Repo.chunk_stream(1_000, :batches)
  13. |> Stream.each(fn records ->
  14. notification_ids = Enum.map(records, fn %{id: id} -> id end)
  15. Repo.delete_all(
  16. from(n in "notifications",
  17. where: n.id in ^notification_ids
  18. )
  19. )
  20. end)
  21. |> Stream.run()
  22. end
  23. def down do
  24. :ok
  25. end
  26. end