From 05d4989795b79683933aa602cd427c57ded10e2f Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 29 Jul 2024 13:54:26 -0400 Subject: Insert replacement jobs in the new format if any remain undelivered The old jobs remain and will fail gracefully --- .../20240729163838_publisher_job_change.exs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 priv/repo/migrations/20240729163838_publisher_job_change.exs (limited to 'priv') diff --git a/priv/repo/migrations/20240729163838_publisher_job_change.exs b/priv/repo/migrations/20240729163838_publisher_job_change.exs new file mode 100644 index 000000000..08d73b5ad --- /dev/null +++ b/priv/repo/migrations/20240729163838_publisher_job_change.exs @@ -0,0 +1,27 @@ +defmodule Pleroma.Repo.Migrations.PublisherJobChange do + use Ecto.Migration + + alias Pleroma.Activity + import Ecto.Query + + def up do + query = + from(j in Oban.Job, + where: j.worker == "Pleroma.Workers.PublisherWorker", + where: j.state in ["available", "retryable"] + ) + + jobs = + Oban |> Oban.config() |> Oban.Repo.all(query) + + Enum.each(jobs, fn job -> + args = job.args + activity = Activity.get_by_ap_id(args["id"]) + + updated_args = Map.put(args, "activity_id", activity.id) + + Pleroma.Workers.PublisherWorker.new(updated_args) + |> Oban.insert() + end) + end +end -- cgit v1.2.3 From 1bce582f0de896b2a84cc2ef44f82646276dc255 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 30 Jul 2024 10:48:06 -0400 Subject: Fix migration crashing due to Oban not running We can use Pleroma.Repo to fetch the jobs --- priv/repo/migrations/20240729163838_publisher_job_change.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'priv') diff --git a/priv/repo/migrations/20240729163838_publisher_job_change.exs b/priv/repo/migrations/20240729163838_publisher_job_change.exs index 08d73b5ad..3449e3b3b 100644 --- a/priv/repo/migrations/20240729163838_publisher_job_change.exs +++ b/priv/repo/migrations/20240729163838_publisher_job_change.exs @@ -2,6 +2,7 @@ defmodule Pleroma.Repo.Migrations.PublisherJobChange do use Ecto.Migration alias Pleroma.Activity + alias Pleroma.Repo import Ecto.Query def up do @@ -11,8 +12,7 @@ defmodule Pleroma.Repo.Migrations.PublisherJobChange do where: j.state in ["available", "retryable"] ) - jobs = - Oban |> Oban.config() |> Oban.Repo.all(query) + jobs = Repo.all(query) Enum.each(jobs, fn job -> args = job.args -- cgit v1.2.3