pleroma/priv/repo/migrations/20240729163838_publisher_job_change.exs
Mark Felder 1bce582f0d Fix migration crashing due to Oban not running
We can use Pleroma.Repo to fetch the jobs
2024-07-30 10:58:10 -04:00

28 lines
613 B
Elixir

defmodule Pleroma.Repo.Migrations.PublisherJobChange do
use Ecto.Migration
alias Pleroma.Activity
alias Pleroma.Repo
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 = 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