Migrations: Add chat_id, seen index to ChatMessageReferences
authorlain <lain@soykaf.club>
Wed, 3 Jun 2020 12:32:19 +0000 (14:32 +0200)
committerlain <lain@soykaf.club>
Wed, 3 Jun 2020 12:34:33 +0000 (14:34 +0200)
This ensures fast count of unseen messages

priv/repo/migrations/20200603122732_add_seen_index_to_chat_message_references.exs [new file with mode: 0644]

diff --git a/priv/repo/migrations/20200603122732_add_seen_index_to_chat_message_references.exs b/priv/repo/migrations/20200603122732_add_seen_index_to_chat_message_references.exs
new file mode 100644 (file)
index 0000000..a5065d6
--- /dev/null
@@ -0,0 +1,12 @@
+defmodule Pleroma.Repo.Migrations.AddSeenIndexToChatMessageReferences do
+  use Ecto.Migration
+
+  def change do
+    create(
+      index(:chat_message_references, [:chat_id],
+        where: "seen = false",
+        name: "unseen_messages_count_index"
+      )
+    )
+  end
+end