summaryrefslogtreecommitdiff
path: root/priv
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2018-03-08 12:29:02 +0000
committerlambda <pleromagit@rogerbraun.net>2018-03-08 12:29:02 +0000
commit460062f2b04220ffcd8f20aa842cc95582d1f849 (patch)
treef56c298bed6b289aa2dd81766862265ccef05947 /priv
parent0f2bf3eefb0adba13a3f3d37e8d8b1bd414a33e4 (diff)
parent611ca385dea3d611a97579000311cc42684305e6 (diff)
downloadpleroma-460062f2b04220ffcd8f20aa842cc95582d1f849.tar.gz
pleroma-460062f2b04220ffcd8f20aa842cc95582d1f849.zip
Merge branch 'feature/activitypub' into 'develop'
Feature/activitypub See merge request pleroma/pleroma!67
Diffstat (limited to 'priv')
-rw-r--r--priv/repo/migrations/20171212163643_add_recipients_to_activities.exs11
-rw-r--r--priv/repo/migrations/20171212164525_fill_recipients_in_activities.exs21
-rw-r--r--priv/repo/migrations/20180221210540_make_following_postgres_array.exs18
3 files changed, 50 insertions, 0 deletions
diff --git a/priv/repo/migrations/20171212163643_add_recipients_to_activities.exs b/priv/repo/migrations/20171212163643_add_recipients_to_activities.exs
new file mode 100644
index 000000000..7bce78108
--- /dev/null
+++ b/priv/repo/migrations/20171212163643_add_recipients_to_activities.exs
@@ -0,0 +1,11 @@
+defmodule Pleroma.Repo.Migrations.AddRecipientsToActivities do
+ use Ecto.Migration
+
+ def change do
+ alter table(:activities) do
+ add :recipients, {:array, :string}
+ end
+
+ create index(:activities, [:recipients], using: :gin)
+ end
+end
diff --git a/priv/repo/migrations/20171212164525_fill_recipients_in_activities.exs b/priv/repo/migrations/20171212164525_fill_recipients_in_activities.exs
new file mode 100644
index 000000000..1fcc0dabb
--- /dev/null
+++ b/priv/repo/migrations/20171212164525_fill_recipients_in_activities.exs
@@ -0,0 +1,21 @@
+defmodule Pleroma.Repo.Migrations.FillRecipientsInActivities 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 recipients = array(select jsonb_array_elements_text(data->'to')) where id > #{min} and id <= #{max};
+ """)
+ |> IO.inspect
+ end)
+ end
+ end
+end
diff --git a/priv/repo/migrations/20180221210540_make_following_postgres_array.exs b/priv/repo/migrations/20180221210540_make_following_postgres_array.exs
new file mode 100644
index 000000000..98ca7d9d7
--- /dev/null
+++ b/priv/repo/migrations/20180221210540_make_following_postgres_array.exs
@@ -0,0 +1,18 @@
+defmodule Pleroma.Repo.Migrations.MakeFollowingPostgresArray do
+ use Ecto.Migration
+
+ def change do
+ alter table(:users) do
+ add :following_temp, {:array, :string}
+ end
+
+ execute """
+ update users set following_temp = array(select jsonb_array_elements_text(following));
+ """
+
+ alter table(:users) do
+ remove :following
+ end
+ rename table(:users), :following_temp, to: :following
+ end
+end