Migrations: Add unique index to ChatMessageReferences.
authorlain <lain@soykaf.club>
Wed, 3 Jun 2020 11:13:44 +0000 (13:13 +0200)
committerlain <lain@soykaf.club>
Wed, 3 Jun 2020 11:13:44 +0000 (13:13 +0200)
priv/repo/migrations/20200603105113_add_unique_index_to_chat_message_references.exs [new file with mode: 0644]

diff --git a/priv/repo/migrations/20200603105113_add_unique_index_to_chat_message_references.exs b/priv/repo/migrations/20200603105113_add_unique_index_to_chat_message_references.exs
new file mode 100644 (file)
index 0000000..1101be9
--- /dev/null
@@ -0,0 +1,14 @@
+defmodule Pleroma.Repo.Migrations.BackfillChatMessageReferences do
+  use Ecto.Migration
+
+  alias Pleroma.Chat
+  alias Pleroma.ChatMessageReference
+  alias Pleroma.Object
+  alias Pleroma.Repo
+
+  import Ecto.Query
+
+  def change do
+    create(unique_index(:chat_message_references, [:object_id, :chat_id]))
+  end
+end