您的位置:首页 > 产品设计 > UI/UE

postgresql duplicate key violates unique constraint

2016-04-08 19:31 721 查看
> Throws an exception due to the following SQL error: duplicate key
> violates unique constraint.

Your primary key index isn't in sync or something.

Can you login to psql and run the following?

SELECT MAX(id) FROM entities;

What is the result?

Then run...

SELECT nextval('entities_id_seq');

This should be higher than the last result.

Is it  the same or lower? If so... did you do some importing or
restoring? (your sequence might be off)

If it's not higher... run this to try and fix it. (run a quick
pg_dump first...)

SELECT setval('entities_id_seq', (SELECT MAX(id) FROM entities)+1);

reload your app...and see if its still happening.

Good luck!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  postgresql