remove PurgeExpiredActivity from Oban db config
authorAlexander Strizhakov <alex.strizhakov@gmail.com>
Fri, 13 Nov 2020 06:07:08 +0000 (09:07 +0300)
committerlain <lain@soykaf.club>
Tue, 22 Dec 2020 19:47:20 +0000 (20:47 +0100)
priv/repo/migrations/20201113060459_remove_purge_expired_activity_worker_from_oban_config.exs [new file with mode: 0644]

diff --git a/priv/repo/migrations/20201113060459_remove_purge_expired_activity_worker_from_oban_config.exs b/priv/repo/migrations/20201113060459_remove_purge_expired_activity_worker_from_oban_config.exs
new file mode 100644 (file)
index 0000000..fe31f44
--- /dev/null
@@ -0,0 +1,19 @@
+defmodule Pleroma.Repo.Migrations.RemovePurgeExpiredActivityWorkerFromObanConfig do
+  use Ecto.Migration
+
+  def change do
+    with %Pleroma.ConfigDB{} = config <-
+           Pleroma.ConfigDB.get_by_params(%{group: :pleroma, key: Oban}),
+         crontab when is_list(crontab) <- config.value[:crontab],
+         index when is_integer(index) <-
+           Enum.find_index(crontab, fn {_, worker} ->
+             worker == Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker
+           end) do
+      updated_value = Keyword.put(config.value, :crontab, List.delete_at(crontab, index))
+
+      config
+      |> Ecto.Changeset.change(value: updated_value)
+      |> Pleroma.Repo.update()
+    end
+  end
+end