diff options
author | Mark Felder <feld@feld.me> | 2024-07-29 13:54:26 -0400 |
---|---|---|
committer | Mark Felder <feld@feld.me> | 2024-07-29 14:00:46 -0400 |
commit | 05d4989795b79683933aa602cd427c57ded10e2f (patch) | |
tree | 485c0dd363a294790229671b3ca20eb688b96de2 /priv | |
parent | b48fd89a41ad766b79a7a2336737196216cede22 (diff) | |
download | pleroma-05d4989795b79683933aa602cd427c57ded10e2f.tar.gz pleroma-05d4989795b79683933aa602cd427c57ded10e2f.zip |
Insert replacement jobs in the new format if any remain undelivered
The old jobs remain and will fail gracefully
Diffstat (limited to 'priv')
-rw-r--r-- | priv/repo/migrations/20240729163838_publisher_job_change.exs | 27 |
1 files changed, 27 insertions, 0 deletions
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 |