alias Pleroma.User
alias Pleroma.Repo
- def change do
+ def up do
query =
from(u in User,
where: u.local == true,
|> 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)
remove(:bookmarks)
end
end
+
+ def down do
+ alter table(:users) do
+ add :bookmarks, {:array, :string}, null: false, default: []
+ end
+ end
end