diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-11-10 17:37:54 +0100 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-11-10 17:37:54 +0100 |
commit | 1d3d66a841253a244e5166726ba4f3d1f21651c3 (patch) | |
tree | b1d0c230d9bfebd139b527392e5399fa647781d9 /priv | |
parent | 6e9c22c0afaa67f0b94f602eceef5c57b7c9192f (diff) | |
parent | 1b8ad9f731708a3231ef01a5db1fba2516d48d98 (diff) | |
download | pleroma-1d3d66a841253a244e5166726ba4f3d1f21651c3.tar.gz pleroma-1d3d66a841253a244e5166726ba4f3d1f21651c3.zip |
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into develop
Diffstat (limited to 'priv')
3 files changed, 34 insertions, 4 deletions
diff --git a/priv/repo/migrations/20171109091239_add_actor_to_activity.exs b/priv/repo/migrations/20171109091239_add_actor_to_activity.exs index bac53972c..2d8b60a91 100644 --- a/priv/repo/migrations/20171109091239_add_actor_to_activity.exs +++ b/priv/repo/migrations/20171109091239_add_actor_to_activity.exs @@ -8,10 +8,6 @@ defmodule Pleroma.Repo.Migrations.AddActorToActivity do add :actor, :string end - execute """ - update activities set actor = data->>'actor'; - """ - create index(:activities, [:actor, "id DESC NULLS LAST"], concurrently: true) end diff --git a/priv/repo/migrations/20171109114020_fill_actor_field.exs b/priv/repo/migrations/20171109114020_fill_actor_field.exs new file mode 100644 index 000000000..255ca46d5 --- /dev/null +++ b/priv/repo/migrations/20171109114020_fill_actor_field.exs @@ -0,0 +1,26 @@ +defmodule Pleroma.Repo.Migrations.FillActorField do + use Ecto.Migration + + alias Pleroma.{Repo, Activity} + + def up do + max = Repo.aggregate(Activity, :max, :id) + if max do + IO.puts("#{max} activities") + chunks = 0..(round(max / 10_000)) + + Enum.each(chunks, fn (i) -> + min = i * 10_000 + max = min + 10_000 + execute(""" + update activities set actor = data->>'actor' where id > #{min} and id <= #{max}; + """) + |> IO.inspect + end) + end + end + + def down do + end +end + diff --git a/priv/repo/migrations/20171109141309_add_sort_index_to_activities.exs b/priv/repo/migrations/20171109141309_add_sort_index_to_activities.exs new file mode 100644 index 000000000..2d21c56ca --- /dev/null +++ b/priv/repo/migrations/20171109141309_add_sort_index_to_activities.exs @@ -0,0 +1,8 @@ +defmodule Pleroma.Repo.Migrations.AddSortIndexToActivities do + use Ecto.Migration + @disable_ddl_transaction true + + def change do + create index(:activities, ["id desc nulls last"], concurrently: true) + end +end |