|> Ecto.Changeset.unique_constraint(:name)
end
Chat.User.create("test","test")
[debug] QUERY ERROR db=82.0ms queue=59.2ms
INSERT INTO user (name,password) VALUES (?,?) ["test", "CY9rzUYh03PK3k6DJie09g=="]
** (Ecto.ConstraintError) constraint error when attempting to insert struct:
* name (unique_constraint)
If you would like to stop this constraint violation from raising an
exception and instead add it as an error to your changeset, please
call unique_constraint/3 on your changeset with the constraint
:name as an option.
The changeset defined the following constraints:
* user_name_index (unique_constraint)
(ecto) lib/ecto/repo/schema.ex:689: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3
(elixir) lib/enum.ex:1336: Enum."-map/2-lists^map/1-0-"/2
(ecto) lib/ecto/repo/schema.ex:674: Ecto.Repo.Schema.constraints_to_errors/3
(ecto) lib/ecto/repo/schema.ex:274: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
Почему таблица называется user?
Обсуждают сегодня