citusdata/django-multitenant

Duplicate Constraint fails when I try to save model on Admin Panel

Alihassanc5 opened this issue · 1 comments

I am getting this error when I change the tenant and save the model through admin panel:

image

How can I resolve this error?

Check to make sure the postgresql sequence that was created to add an ID for that table is set correctly and the next ID is Max(id)+1

Or it could be that you tried to update the id manually.

You can reset it using the following:
SELECT setval('tablename_id_seq', (SELECT COALESCE(max(id),0)+1 FROM "tablenames"), false);