DRFOR
bug: 重复主键
IntegrityError: duplicate key value violates unique constraint "core_xxx_pkey"DETAIL: Key (id)=(2) already exists.
参考
原因: 迁移过程中,导致数据pk被重置为0
(pets) ➜ booksong git:(master) ✗ python manage.py sqlsequencereset core BEGIN;
SELECT setval(pg_get_serial_sequence(""core_user_groups"","id"), coalesce(max("id"), 1), max("id") IS NOT null) FROM "core_user_groups";
COMMIT;
(pets) ➜ booksong git:(master)
重新设置pk为max(id)
SELECT setval(pg_get_serial_sequence(""core_showtime"","id"), coalesce(max("id"), 1), max("id") IS NOT null) FROM "core_showtime";
以上是 DRFOR 的全部内容, 来源链接: utcz.com/z/512523.html