Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
normandy
pleroma
Commits
20b8b877
Commit
20b8b877
authored
7 years ago
by
Roger Braun
Browse files
Options
Downloads
Patches
Plain Diff
Update in chunks.
parent
f1d27a5f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
priv/repo/migrations/20171109091239_add_actor_to_activity.exs
+14
-3
14 additions, 3 deletions
.../repo/migrations/20171109091239_add_actor_to_activity.exs
with
14 additions
and
3 deletions
priv/repo/migrations/20171109091239_add_actor_to_activity.exs
+
14
−
3
View file @
20b8b877
defmodule
Pleroma
.
Repo
.
Migrations
.
AddActorToActivity
do
use
Ecto
.
Migration
alias
Pleroma
.
{
Repo
,
Activity
}
@disable_ddl_transaction
true
def
up
do
...
...
@@ -8,9 +10,18 @@ defmodule Pleroma.Repo.Migrations.AddActorToActivity do
add
:actor
,
:string
end
execute
"""
update activities set actor = data->>'actor';
"""
max
=
Repo
.
aggregate
(
Activity
,
:max
,
:id
)
IO
.
puts
(
"
#{
max
}
activities"
)
chunks
=
0
..
(
round
(
max
/
10_000
))
Enum
.
each
(
chunks
,
fn
(
i
)
->
min
=
i
*
10_000
max
=
min
+
10_000
IO
.
puts
(
"Updating
#{
min
}
"
)
execute
"""
update activities set actor = data->>'actor' where id > #{min} and id <= #{max};
"""
end
)
create
index
(
:activities
,
[
:actor
,
"id DESC NULLS LAST"
],
concurrently:
true
)
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment