20200802170532_fix_legacy_tags: Select only fields the migration needs
authorrinpatch <rinpatch@sdf.org>
Fri, 7 Aug 2020 19:05:17 +0000 (22:05 +0300)
committerrinpatch <rinpatch@sdf.org>
Mon, 10 Aug 2020 08:55:58 +0000 (11:55 +0300)
Selecting the full struct will break as soon as a new field is added.

priv/repo/migrations/20200802170532_fix_legacy_tags.exs

index f7274b44e4deea9c2d26ed7f8b9eefe0de1ee6ee..a84b5d0f63793b9e5967c55318d0a026a7bfe6c1 100644 (file)
@@ -18,7 +18,10 @@ defmodule Pleroma.Repo.Migrations.FixLegacyTags do
   def change do
     legacy_tags = Map.keys(@old_new_map)
 
   def change do
     legacy_tags = Map.keys(@old_new_map)
 
-    from(u in User, where: fragment("? && ?", u.tags, ^legacy_tags))
+    from(u in User,
+      where: fragment("? && ?", u.tags, ^legacy_tags),
+      select: struct(u, [:tags, :id])
+    )
     |> Repo.all()
     |> Enum.each(fn user ->
       fix_tags_changeset(user)
     |> Repo.all()
     |> Enum.each(fn user ->
       fix_tags_changeset(user)