My south migration history table is causing integrity errors every time I try to run a new migration. Here is the error:
django.db.utils.IntegrityError: duplicate key value violates unique constraint "south_migrationhistory_pkey"
DETAIL: Key (id)=(40) already exists.
So far, this is only happening locally. I have deleted the database and rebuilt a number of times, and each time all existing migrations run smoothly. But as soon as I create a new migration, I get this error again.
Migration 40 happens to be a third party migration (djangoratings), so I don't believe it is a problem with that migration file.
Any help would be greatly appreciated!
How about
SELECT setval('south_migrationhistory_id_seq', (SELECT MAX(id) FROM south_migrationhistory));
That worked for me.
You probably should do a pg_dump
beforehand, just in case it all goes wrong.
I'm using postgres, you might need to use a slightly different command to update your database sequence for other databases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With