2024-07-29 17:54:26 +00:00
|
|
|
defmodule Pleroma.Repo.Migrations.PublisherJobChange do
|
|
|
|
use Ecto.Migration
|
|
|
|
|
|
|
|
alias Pleroma.Activity
|
2024-07-30 14:48:06 +00:00
|
|
|
alias Pleroma.Repo
|
2024-07-29 17:54:26 +00:00
|
|
|
import Ecto.Query
|
|
|
|
|
|
|
|
def up do
|
|
|
|
query =
|
|
|
|
from(j in Oban.Job,
|
|
|
|
where: j.worker == "Pleroma.Workers.PublisherWorker",
|
|
|
|
where: j.state in ["available", "retryable"]
|
|
|
|
)
|
|
|
|
|
2024-07-30 14:48:06 +00:00
|
|
|
jobs = Repo.all(query)
|
2024-07-29 17:54:26 +00:00
|
|
|
|
|
|
|
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
|