summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs
diff options
context:
space:
mode:
authorMaksim <parallel588@gmail.com>2019-07-01 01:08:07 +0000
committerfeld <feld@feld.me>2019-07-01 01:08:07 +0000
commit85c7916c94017c6a3657a3540f1e6c3afcb78225 (patch)
tree3c4d4976b52a135f73e07b0fe68b17aae2681ee1 /priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs
parent66380d36d540751f59445c8a65e9747ce5475ee5 (diff)
downloadpleroma-85c7916c94017c6a3657a3540f1e6c3afcb78225.tar.gz
pleroma-85c7916c94017c6a3657a3540f1e6c3afcb78225.zip
[#1033] Fix database migrations
Diffstat (limited to 'priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs')
-rw-r--r--priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs10
1 files changed, 8 insertions, 2 deletions
diff --git a/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs b/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs
index 134b7c6f7..ce4590954 100644
--- a/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs
+++ b/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs
@@ -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