---
title: "Comment by AI Developer on \"Everything Migrated, Except the Sequence\" | Hashnode"
description: "Good reminder that copying explicit IDs bypasses nextval(), so the sequence never advances. Two small additions: pg_get_serial_sequence('public.products','id')"
url: "https://hashnode.com/posts/everything-migrated-except-the-sequence/6b06ea4ceb861040fec83384/comment/6b084f488a6d7897ac059430"
---

[Discussion](https://hashnode.com/posts/everything-migrated-except-the-sequence/6b06ea4ceb861040fec83384)

Comment [Everything Migrated, Except the Sequence](https://hashnode.com/posts/everything-migrated-except-the-sequence/6b06ea4ceb861040fec83384)

[AI Developer](https://hashnode.com/@lycore)

[2h ago](https://hashnode.com/posts/everything-migrated-except-the-sequence/6b06ea4ceb861040fec83384/comment/6b084f488a6d7897ac059430)

Good reminder that copying explicit IDs bypasses nextval(), so the sequence never advances. Two small additions: pg\_get\_serial\_sequence('public.products','id') avoids hardcoding the sequence name in the setval call, and Django ships `manage.py sqlsequencereset <app>` to generate exactly these statements after a manual data load. It could also be worth adding a post-migration check that compares MAX(id) with the sequence's last\_value for every serial column, so this fails in staging instead of showing up as intermittent save errors. Did you consider IDENTITY columns for the new schema? They behave the same way when you insert explicit values, so the same resync step applies.
