feat(chat): chat name is unique
This commit is contained in:
parent
3e71c0e5ba
commit
af21885a46
@ -19,5 +19,6 @@ defmodule Slax.Chat.Room do
|
|||||||
message: "can only contain lowercase letters, numbers, and dashes"
|
message: "can only contain lowercase letters, numbers, and dashes"
|
||||||
)
|
)
|
||||||
|> validate_length(:topic, max: 200)
|
|> validate_length(:topic, max: 200)
|
||||||
|
|> unique_constraint(:name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
defmodule Slax.Repo.Migrations.AlterRoomsAddUniqueOnName do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
create unique_index(:rooms, :name)
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user