diff options
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 |