Merge branch 'develop' into feature/reports-groups-and-multiple-state-update
[akkoma] / priv / repo / migrations / 20190414125034_migrate_old_bookmarks.exs
index 134b7c6f769285e08d0dd724e0b87e003a0b2042..f3928a14962ce86b0bb0daeb03e320dd2d2265ec 100644 (file)
@@ -6,7 +6,7 @@ defmodule Pleroma.Repo.Migrations.MigrateOldBookmarks do
   alias Pleroma.User
   alias Pleroma.Repo
 
-  def change do
+  def up do
     query =
       from(u in User,
         where: u.local == true,
@@ -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)
-       unless is_nil(activity), do: {:ok, _} = Bookmark.create(user_id, activity.id)
+        unless is_nil(activity), do: {:ok, _} = Bookmark.create(user_id, activity.id)
       end)
     end)
 
@@ -26,4 +26,10 @@ defmodule Pleroma.Repo.Migrations.MigrateOldBookmarks do
       remove(:bookmarks)
     end
   end
+
+  def down do
+    alter table(:users) do
+      add(:bookmarks, {:array, :string}, null: false, default: [])
+    end
+  end
 end