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
6bf26158
Commit
6bf26158
authored
7 years ago
by
Roger Braun
Browse files
Options
Downloads
Patches
Plain Diff
Update activities in own migration.
parent
20b8b877
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
priv/repo/migrations/20171109091239_add_actor_to_activity.exs
+0
-15
0 additions, 15 deletions
.../repo/migrations/20171109091239_add_actor_to_activity.exs
priv/repo/migrations/20171109114020_fill_actor_field.exs
+25
-0
25 additions, 0 deletions
priv/repo/migrations/20171109114020_fill_actor_field.exs
with
25 additions
and
15 deletions
priv/repo/migrations/20171109091239_add_actor_to_activity.exs
+
0
−
15
View file @
6bf26158
defmodule
Pleroma
.
Repo
.
Migrations
.
AddActorToActivity
do
use
Ecto
.
Migration
alias
Pleroma
.
{
Repo
,
Activity
}
@disable_ddl_transaction
true
def
up
do
...
...
@@ -10,19 +8,6 @@ defmodule Pleroma.Repo.Migrations.AddActorToActivity do
add
:actor
,
:string
end
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.
priv/repo/migrations/20171109114020_fill_actor_field.exs
0 → 100644
+
25
−
0
View file @
6bf26158
defmodule
Pleroma
.
Repo
.
Migrations
.
FillActorField
do
use
Ecto
.
Migration
alias
Pleroma
.
{
Repo
,
Activity
}
def
up
do
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};
"""
)
|>
IO
.
inspect
end
)
end
def
down
do
end
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