aboutsummaryrefslogtreecommitdiff
path: root/priv
diff options
context:
space:
mode:
Diffstat (limited to 'priv')
-rw-r--r--priv/repo/migrations/20190710115833_add_following_address_to_user.exs9
-rw-r--r--priv/repo/migrations/20190710125051_add_following_address_index_to_user.exs8
-rw-r--r--priv/repo/migrations/20190710125158_add_following_address_from_source_data.exs20
-rw-r--r--priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs24
4 files changed, 61 insertions, 0 deletions
diff --git a/priv/repo/migrations/20190710115833_add_following_address_to_user.exs b/priv/repo/migrations/20190710115833_add_following_address_to_user.exs
new file mode 100644
index 000000000..fe30472a1
--- /dev/null
+++ b/priv/repo/migrations/20190710115833_add_following_address_to_user.exs
@@ -0,0 +1,9 @@
+defmodule Pleroma.Repo.Migrations.AddFollowingAddressToUser do
+ use Ecto.Migration
+
+ def change do
+ alter table(:users) do
+ add(:following_address, :string, unique: true)
+ end
+ end
+end
diff --git a/priv/repo/migrations/20190710125051_add_following_address_index_to_user.exs b/priv/repo/migrations/20190710125051_add_following_address_index_to_user.exs
new file mode 100644
index 000000000..0cbfb71f4
--- /dev/null
+++ b/priv/repo/migrations/20190710125051_add_following_address_index_to_user.exs
@@ -0,0 +1,8 @@
+defmodule Pleroma.Repo.Migrations.AddFollowingAddressIndexToUser do
+ use Ecto.Migration
+
+ @disable_ddl_transaction true
+ def change do
+ create(index(:users, [:following_address], concurrently: true))
+ end
+end
diff --git a/priv/repo/migrations/20190710125158_add_following_address_from_source_data.exs b/priv/repo/migrations/20190710125158_add_following_address_from_source_data.exs
new file mode 100644
index 000000000..779aa382e
--- /dev/null
+++ b/priv/repo/migrations/20190710125158_add_following_address_from_source_data.exs
@@ -0,0 +1,20 @@
+defmodule Pleroma.Repo.Migrations.AddFollowingAddressFromSourceData do
+ use Ecto.Migration
+ import Ecto.Query
+ alias Pleroma.User
+
+ def change do
+ query =
+ User.external_users_query()
+ |> select([u], struct(u, [:id, :ap_id, :info]))
+
+ Pleroma.Repo.stream(query)
+ |> Enum.each(fn
+ %{info: %{source_data: source_data}} = user ->
+ Ecto.Changeset.cast(user, %{following_address: source_data["following"]}, [
+ :following_address
+ ])
+ |> Pleroma.Repo.update()
+ end)
+ end
+end
diff --git a/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs
new file mode 100644
index 000000000..50669902e
--- /dev/null
+++ b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs
@@ -0,0 +1,24 @@
+defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do
+ use Ecto.Migration
+ alias Pleroma.User
+
+ def change do
+ query =
+ User.Query.build(%{
+ local: true,
+ active: true,
+ order_by: :id
+ })
+
+ Pleroma.Repo.stream(query)
+ |> Enum.each(fn
+ %{info: %{mutes: mutes} = info} = user ->
+ info_cng =
+ Ecto.Changeset.cast(info, %{muted_notifications: mutes}, [:muted_notifications])
+
+ Ecto.Changeset.change(user)
+ |> Ecto.Changeset.put_embed(:info, info_cng)
+ |> Pleroma.Repo.update()
+ end)
+ end
+end