logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

20240904142434_assign_app_user.exs (462B)


  1. defmodule Pleroma.Repo.Migrations.AssignAppUser do
  2. use Ecto.Migration
  3. alias Pleroma.Repo
  4. alias Pleroma.Web.OAuth.App
  5. alias Pleroma.Web.OAuth.Token
  6. def up do
  7. Repo.all(Token)
  8. |> Enum.group_by(fn x -> Map.get(x, :app_id) end)
  9. |> Enum.each(fn {_app_id, tokens} ->
  10. token =
  11. Enum.filter(tokens, fn x -> not is_nil(x.user_id) end)
  12. |> List.first()
  13. App.maybe_update_owner(token)
  14. end)
  15. end
  16. def down, do: :ok
  17. end