#30681: SQL script from python manage.py sqlsequencereset doesn't work with
Postgres 11.3
-------------------------------------+-------------------------------------
Reporter: ipa | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 2.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
After migration to postgres I had to resync the primary key and used the
following command.
python manage.py sqlsequencereset app | python manage.py dbshell
After that, the PK was still out of sync and I got PK violations. The
output from sqlsequencereset was:
BEGIN;
SELECT setval(pg_get_serial_sequence('"tablename"','id'),
coalesce(max("id"), 1), max("id") IS NOT null) FROM "tablename";
COMMIT;
After that I tried a different command which I wrote manually and worked.
SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename)+1)
It seems that the SQL produces by sqlsequencereset doesn't work on some
postgres versions.
Postgres Version 11.3
--
Ticket URL: <https://code.djangoproject.com/ticket/30681>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/046.798032075b6ca44eba2798731c3a7b9f%40djangoproject.com.