migration optimization
changelog wording
This commit is contained in:
parent
17b5b78737
commit
6322c1e123
@ -54,7 +54,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- Deps: Updated Cowboy to 2.6
|
- Deps: Updated Cowboy to 2.6
|
||||||
- Deps: Updated Ecto to 3.0.7
|
- Deps: Updated Ecto to 3.0.7
|
||||||
- Don't ship finmoji by default, they can be installed as an emoji pack
|
- Don't ship finmoji by default, they can be installed as an emoji pack
|
||||||
- `User.bookmarks` in separate table, added support max_id & since_id for bookmark timeline endpoints.
|
- Mastodon API: Added support max_id & since_id for bookmark timeline endpoints.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Followers counter not being updated when a follower is blocked
|
- Followers counter not being updated when a follower is blocked
|
||||||
|
@ -1,16 +1,26 @@
|
|||||||
defmodule Pleroma.Repo.Migrations.MigrateOldBookmarks do
|
defmodule Pleroma.Repo.Migrations.MigrateOldBookmarks do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
import Ecto.Query
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
alias Pleroma.Bookmark
|
alias Pleroma.Bookmark
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
|
|
||||||
def up do
|
def up do
|
||||||
Repo.all(User)
|
query =
|
||||||
|> Enum.each(fn user ->
|
from(u in User,
|
||||||
Enum.each(user.old_bookmarks, fn id ->
|
where: u.local == true,
|
||||||
activity = Activity.get_create_by_object_ap_id(id)
|
where: fragment("array_length(?, 1)", u.old_bookmarks) > 0,
|
||||||
{:ok, _} = Bookmark.create(user.id, activity.id)
|
select: %{id: u.id, old_bookmarks: u.old_bookmarks}
|
||||||
|
)
|
||||||
|
|
||||||
|
Repo.transaction(fn ->
|
||||||
|
Repo.stream(query)
|
||||||
|
|> Enum.each(fn user ->
|
||||||
|
Enum.each(user.old_bookmarks, fn id ->
|
||||||
|
activity = Activity.get_create_by_object_ap_id(id)
|
||||||
|
{:ok, _} = Bookmark.create(user.id, activity.id)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user