Unhandled rejection SequelizeUniqueConstraintError: Validation error

后端 未结 5 559
花落未央
花落未央 2021-02-01 23:47

I\'m getting this error:

Unhandled rejection SequelizeUniqueConstraintError: Validation error

How can I fix this?

This is my models/use

5条回答
  •  佛祖请我去吃肉
    2021-02-02 00:27

    Building on @Ricardo Machado's answer, if you add unique:true to a model and already have values in an existing table that wouldn't be allowed under this new constraint you will get this error. To fix you can manually delete the rows or delete the table and so Sequelize builds it again.

提交回复
热议问题