mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-11-14 21:12:00 +00:00
e853cfe7c3
This reverts merge request !3825
28 lines
677 B
Elixir
28 lines
677 B
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Repo.Migrations.GenerateUnsetUserKeys do
|
|
use Ecto.Migration
|
|
import Ecto.Query
|
|
alias Pleroma.Keys
|
|
alias Pleroma.Repo
|
|
alias Pleroma.User
|
|
|
|
def change do
|
|
query =
|
|
from(u in User,
|
|
where: u.local == true,
|
|
where: is_nil(u.keys),
|
|
select: u
|
|
)
|
|
|
|
Repo.stream(query)
|
|
|> Enum.each(fn user ->
|
|
with {:ok, pem} <- Keys.generate_rsa_pem() do
|
|
Ecto.Changeset.cast(user, %{keys: pem}, [:keys])
|
|
|> Repo.update()
|
|
end
|
|
end)
|
|
end
|
|
end
|