repo: add migration to fill recipient_users column
This commit is contained in:
parent
cb3772f0ce
commit
c755d197f7
@ -0,0 +1,31 @@
|
||||
defmodule Pleroma.Repo.Migrations.FillRecipientUsersInActivities do
|
||||
use Ecto.Migration
|
||||
|
||||
alias Pleroma.RepoStreamer
|
||||
alias Pleroma.User
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
def up do
|
||||
# copy users without as:Public
|
||||
execute("""
|
||||
update activities set recipient_users = array_remove(recipients, 'https://www.w3.org/ns/activitystreams#Public');
|
||||
""")
|
||||
|
||||
# strip followers collections
|
||||
from(
|
||||
u in User,
|
||||
where: not(is_nil(u.follower_address))
|
||||
)
|
||||
|> RepoStreamer.chunk_stream(512)
|
||||
|> Stream.each(fn chunk ->
|
||||
chunk
|
||||
|> Enum.each(fn %User{} = u ->
|
||||
execute("update activities set recipient_users = array_remove(recipient_users, '#{u.follower_address}') where recipient_users && array['#{u.follower_address}'::varchar]")
|
||||
end)
|
||||
end)
|
||||
|> Stream.run()
|
||||
end
|
||||
|
||||
def down, do: :ok
|
||||
end
|
Loading…
Reference in New Issue
Block a user