Insert replacement jobs in the new format if any remain undelivered
The old jobs remain and will fail gracefully
This commit is contained in:
parent
b48fd89a41
commit
05d4989795
2 changed files with 70 additions and 0 deletions
27
priv/repo/migrations/20240729163838_publisher_job_change.exs
Normal file
27
priv/repo/migrations/20240729163838_publisher_job_change.exs
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue