Have you set up the unique_constraint on the database side to go with this? All unique_constraint is basically turn the database constraint error into a nicer error on the elixir side
The unique constraint works by relying on the database to check if the unique constraint has been violated or not and, if so, Ecto converts it into a changeset error.