From e3ca0a7e2d18ca9b3c809282678456d4517d39bc Mon Sep 17 00:00:00 2001
From: Alexander Strizhakov <alex.strizhakov@gmail.com>
Date: Fri, 11 Sep 2020 09:09:28 +0300
Subject: [PATCH] migration to remove old cron jobs

---
 .../20200911055909_remove_cron_jobs.exs       | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 priv/repo/migrations/20200911055909_remove_cron_jobs.exs

diff --git a/priv/repo/migrations/20200911055909_remove_cron_jobs.exs b/priv/repo/migrations/20200911055909_remove_cron_jobs.exs
new file mode 100644
index 000000000..33897d128
--- /dev/null
+++ b/priv/repo/migrations/20200911055909_remove_cron_jobs.exs
@@ -0,0 +1,20 @@
+defmodule Pleroma.Repo.Migrations.RemoveCronJobs do
+  use Ecto.Migration
+
+  import Ecto.Query, only: [from: 2]
+
+  def up do
+    from(j in "oban_jobs",
+      where:
+        j.worker in ^[
+          "Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker",
+          "Pleroma.Workers.Cron.StatsWorker",
+          "Pleroma.Workers.Cron.ClearOauthTokenWorker"
+        ],
+      select: [:id]
+    )
+    |> Pleroma.Repo.delete_all()
+  end
+
+  def down, do: :ok
+end