Migrations: Make user_id index on notifications better for query.
authorlain <lain@soykaf.club>
Wed, 27 May 2020 10:56:15 +0000 (12:56 +0200)
committerlain <lain@soykaf.club>
Wed, 27 May 2020 10:56:15 +0000 (12:56 +0200)
priv/repo/migrations/20200527104138_change_notification_user_index.exs [new file with mode: 0644]

diff --git a/priv/repo/migrations/20200527104138_change_notification_user_index.exs b/priv/repo/migrations/20200527104138_change_notification_user_index.exs
new file mode 100644 (file)
index 0000000..4dcfe6d
--- /dev/null
@@ -0,0 +1,8 @@
+defmodule Pleroma.Repo.Migrations.ChangeNotificationUserIndex do
+  use Ecto.Migration
+
+  def change do
+    drop_if_exists(index(:notifications, [:user_id]))
+    create_if_not_exists(index(:notifications, [:user_id, "id desc nulls last"]))
+  end
+end