Postgresql Sequence update on data migration

49 views
Skip to first unread message

mohamad ali mehdizadeh

unread,
May 25, 2022, 2:23:24 AMMay 25
to Django developers (Contributions to Django itself)
I have a migration from an old table to a new table, so when I migrate also data of old table, I try to keep PrimaryKey values the same as old table. so every thing go well until I see primary key duplicate value errors from Postgresql, I check it and so the Sequence of the new table was not get the last_value of the old table,
I doubt that is it the responsibility of developer to take it to the account or Django can help developer here?

Matthew Pava

unread,
May 25, 2022, 10:33:44 AMMay 25
to django-d...@googlegroups.com

Please see:

https://docs.djangoproject.com/en/dev/ref/django-admin/#sqlsequencereset

 

Also, this question is more for the Django Users mailing list than the Django Developers mailing list.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/fd70a069-0704-40b7-9fe9-e59d87fef22an%40googlegroups.com.

mohammad ali mehdizadeh

unread,
May 25, 2022, 2:11:16 PMMay 25
to django-d...@googlegroups.com
Matthew thank you for your attention
I mean we have a scenario that can make errors.
We have a sequence for a primary key, if we insert some objects with predefined `id` and then we let the sequence create a key for us, then we will have a duplicate primary key error.
Do you mind django want to prevent it? 
Or it's developer responsibility?

Adam Johnson

unread,
May 25, 2022, 2:59:17 PMMay 25
to Django developers (Contributions to Django itself)
Hi!

I think you've found the wrong mailing list for this post. This mailing list is for discussing the development of Django itself, not for support using Django. This means the discussions of bugs and features in Django itself, rather than in your code using it. People on this list are unlikely to answer your support query with their limited time and energy.

For support, please follow the "Getting Help" page: https://docs.djangoproject.com/en/stable/faq/help/ . This will help you find people who are willing to support you, and to ask your question in a way that makes it easy for them to answer.

Thanks for your understanding and all the best,

Adam

Reply all
Reply to author
Forward
0 new messages