Ensure new columns in users can't mess up migrations
Some checks failed
ci/woodpecker/push/woodpecker Pipeline is pending
ci/woodpecker/pr/woodpecker Pipeline failed

This commit is contained in:
FloatingGhost 2022-11-28 12:42:53 +00:00
parent 6523aa9c2a
commit 26bb7fcc39

View file

@ -14,14 +14,14 @@ defmodule Pleroma.Repo.Migrations.GenerateUnsetUserKeys do
from(u in User,
where: u.local == true,
where: is_nil(u.keys),
select: u
select: u.id
)
Repo.stream(query)
|> Enum.each(fn user ->
with {:ok, pem} <- Keys.generate_rsa_pem() do
Ecto.Changeset.cast(user, %{keys: pem}, [:keys])
|> Repo.update()
Ecto.Changeset.cast(%User{id: user}, %{keys: pem}, [:keys])
|> Repo.update(returning: false)
end
end)
end