logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

20240527144418_oban_queues_refactor.exs (1035B)


  1. defmodule Pleroma.Repo.Migrations.ObanQueuesRefactor do
  2. use Ecto.Migration
  3. @changed_queues [
  4. {"attachments_cleanup", "slow"},
  5. {"mailer", "background"},
  6. {"mute_expire", "background"},
  7. {"poll_notifications", "background"},
  8. {"activity_expiration", "slow"},
  9. {"filter_expiration", "background"},
  10. {"token_expiration", "background"},
  11. {"remote_fetcher", "background"},
  12. {"rich_media_expiration", "background"}
  13. ]
  14. def up do
  15. Enum.each(@changed_queues, fn {old, new} ->
  16. execute("UPDATE oban_jobs SET queue = '#{new}' WHERE queue = '#{old}';")
  17. end)
  18. # Handled special as reverting this would not be ideal and leaving it is harmless
  19. execute(
  20. "UPDATE oban_jobs SET queue = 'federator_outgoing' WHERE queue = 'scheduled_activities';"
  21. )
  22. end
  23. def down do
  24. # Just move all slow queue jobs to background queue if we are reverting
  25. # as the slow queue will not be processing jobs
  26. execute("UPDATE oban_jobs SET queue = 'background' WHERE queue = 'slow';")
  27. end
  28. end