It looks like I messed up a database migration and while all sequences are there, they would start at 1
, which triggers errors like:
django.db.utils.IntegrityError: duplicate key value violates unique
constraint "django_admin_log_pkey" DETAIL: Key (id)=(2) already
exists.
Is there a query/script I could run that would run across all tables in the database, look at any columns tied to a sequence and reset those sequences to max(column) + 1
?
Using PostgreSQL v11.
Best Answer
I see you are using Django.
I implemented a command to resolve these issues for all databases in your settings file.