Merge branch 'fix/flaky-migration-episode-666' into 'develop'

20200802170532_fix_legacy_tags: Select only fields the migration needs

See merge request pleroma/pleroma!2863
This commit is contained in:
rinpatch 2020-08-10 09:17:08 +00:00
commit 00a4980c61

View File

@ -18,8 +18,11 @@ defmodule Pleroma.Repo.Migrations.FixLegacyTags do
def change do def change do
legacy_tags = Map.keys(@old_new_map) legacy_tags = Map.keys(@old_new_map)
from(u in User, where: fragment("? && ?", u.tags, ^legacy_tags)) from(u in User,
|> Repo.all() where: fragment("? && ?", u.tags, ^legacy_tags),
select: struct(u, [:tags, :id])
)
|> Repo.chunk_stream(100)
|> Enum.each(fn user -> |> Enum.each(fn user ->
fix_tags_changeset(user) fix_tags_changeset(user)
|> Repo.update() |> Repo.update()