From 4a1e9ce713f3fa7a0b4d4db2f09827b1596a2894 Mon Sep 17 00:00:00 2001
From: Thomas Citharel <tcit@tcit.fr>
Date: Wed, 28 Apr 2021 18:25:21 +0200
Subject: [PATCH] Add constraint on the comment url

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
---
 lib/mobilizon/discussions/comment.ex | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/mobilizon/discussions/comment.ex b/lib/mobilizon/discussions/comment.ex
index bfa0cf6a1..8ec1bd75a 100644
--- a/lib/mobilizon/discussions/comment.ex
+++ b/lib/mobilizon/discussions/comment.ex
@@ -126,6 +126,7 @@ defmodule Mobilizon.Discussions.Comment do
     |> put_assoc(:media, Map.get(attrs, :media, []))
     |> put_tags(attrs)
     |> put_mentions(attrs)
+    |> unique_constraint(:url, name: :comments_url_index)
   end
 
   @spec maybe_generate_uuid(Ecto.Changeset.t()) :: Ecto.Changeset.t()