﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30681	SQL script from sqlsequencereset doesn't work on Postgres 11.3.	Iwan Paolucci	nobody	"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"	Bug	closed	Database layer (models, ORM)	dev	Normal	worksforme			Unreviewed	0	0	0	0	0	0
