citusdata / django-multitenant

Python/Django support for distributed multi-tenant databases like Postgres+Citus
MIT License
707 stars 116 forks source link

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

Open Alihassanc5 opened 2 weeks ago

Alihassanc5 commented 2 weeks ago

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

image

How can I resolve this error?

andyp05 commented 2 weeks ago

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);