Ensure apps are assigned to users
This commit is contained in:
parent
427da7a99a
commit
7bd0750787
5 changed files with 42 additions and 1 deletions
21
priv/repo/migrations/20240904142434_assign_app_user.exs
Normal file
21
priv/repo/migrations/20240904142434_assign_app_user.exs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
defmodule Pleroma.Repo.Migrations.AssignAppUser do
|
||||
use Ecto.Migration
|
||||
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.Web.OAuth.App
|
||||
alias Pleroma.Web.OAuth.Token
|
||||
|
||||
def up do
|
||||
Repo.all(Token)
|
||||
|> Enum.group_by(fn x -> Map.get(x, :app_id) end)
|
||||
|> Enum.each(fn {_app_id, tokens} ->
|
||||
token =
|
||||
Enum.filter(tokens, fn x -> not is_nil(x.user_id) end)
|
||||
|> List.first()
|
||||
|
||||
App.maybe_update_owner(token)
|
||||
end)
|
||||
end
|
||||
|
||||
def down, do: :ok
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue