Fix MigrateOldBookmarks migration crashing on deleted activities
authorrinpatch <rinpatch@sdf.org>
Mon, 29 Apr 2019 18:25:30 +0000 (21:25 +0300)
committerrinpatch <rinpatch@sdf.org>
Mon, 29 Apr 2019 18:25:30 +0000 (21:25 +0300)
priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs

index ebe69696e6ff68f797b2bffecd1504d600d05367..134b7c6f769285e08d0dd724e0b87e003a0b2042 100644 (file)
@@ -18,7 +18,7 @@ defmodule Pleroma.Repo.Migrations.MigrateOldBookmarks do
     |> Enum.each(fn %{id: user_id, bookmarks: bookmarks} ->
       Enum.each(bookmarks, fn ap_id ->
         activity = Activity.get_create_by_object_ap_id(ap_id)
-        {:ok, _} = Bookmark.create(user_id, activity.id)
+       unless is_nil(activity), do: {:ok, _} = Bookmark.create(user_id, activity.id)
       end)
     end)