feat(chat): chat name is unique

This commit is contained in:
João Paulo Dubas 2024-10-21 23:50:23 +00:00
parent 3e71c0e5ba
commit af21885a46
Signed by: joao.dubas
SSH Key Fingerprint: SHA256:V1mixgOGRc/YMhGx/DNkOSmJxgA2vHNrDZEk3wt/kOA
2 changed files with 8 additions and 0 deletions

View File

@ -19,5 +19,6 @@ defmodule Slax.Chat.Room do
message: "can only contain lowercase letters, numbers, and dashes"
)
|> validate_length(:topic, max: 200)
|> unique_constraint(:name)
end
end

View File

@ -0,0 +1,7 @@
defmodule Slax.Repo.Migrations.AlterRoomsAddUniqueOnName do
use Ecto.Migration
def change do
create unique_index(:rooms, :name)
end
end