Unique: info_pkey

Im use ecto migrated my tables, and already insert some data in the table in a few days ago, Now got the new error using Repo.insert, dont know why. There id key is automatically create and grown up.

** (Ecto.ConstraintError) constraint error when attempting to insert struct:

  • unique: info_pkey

If you would like to convert this constraint into an error, please
call unique_constraint/3 in your changeset and define the proper
constraint name. The changeset has not defined any constraint.

In this case the table has unique index.
And this error is shown up when you trying to insert into the database table but it could not insert since there the inserting has duplicate a unique field value.
Ecto detect the constraint(From the database side) and recommending you to convert this constraint into error and show back to the user by adding unique_constraint(changeset, field, //opts = []) in the model