Postgresql Sequence update on data migration

Skip to first unread message

mohamad ali mehdizadeh

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

May 25, 2022, 10:33:44 AMMay 25

Please see:


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
To view this discussion on the web visit

mohammad ali mehdizadeh

May 25, 2022, 2:11:16 PMMay 25
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

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

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: . 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,


Reply all
Reply to author
0 new messages