Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
6322c1e1
Commit
6322c1e1
authored
Apr 15, 2019
by
Alexander Strizhakov
Browse files
migration optimization
changelog wording
parent
17b5b787
Changes
2
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
6322c1e1
...
...
@@ -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 Ecto to 3.0.7
-
Don't ship finmoji by default, they can be installed as an emoji pack
-
`User.bookmarks`
in separate table, a
dded support max_id & since_id for bookmark timeline endpoints.
-
Mastodon API: A
dded support max_id & since_id for bookmark timeline endpoints.
### Fixed
-
Followers counter not being updated when a follower is blocked
...
...
priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs
View file @
6322c1e1
defmodule
Pleroma
.
Repo
.
Migrations
.
MigrateOldBookmarks
do
use
Ecto
.
Migration
import
Ecto
.
Query
alias
Pleroma
.
Activity
alias
Pleroma
.
Bookmark
alias
Pleroma
.
User
alias
Pleroma
.
Repo
def
up
do
Repo
.
all
(
User
)
|>
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
)
query
=
from
(
u
in
User
,
where:
u
.
local
==
true
,
where:
fragment
(
"array_length(?, 1)"
,
u
.
old_bookmarks
)
>
0
,
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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment