Sequence problem with drizzle-seed
I'm experiencing an issue where after seeding data into a PostgreSQL table with Drizzle ORM, the sequence (users_id_seq) doesn't update to reflect the highest id inserted. Here are the details:
Schema:
Seeding Script:
Problem: I am not be able to insert 11th user manually. After seeding 10 users,
Expected Behavior: The sequence should have been updated to the last inserted id after seeding.
Current Workaround: I manually reset the sequence with
Is there a known issue with how Drizzle handles sequences during bulk seeding, or am I missing something in my setup or seeding approach? Any advice or insights would be greatly appreciated.
Schema:
Seeding Script:
Problem: I am not be able to insert 11th user manually. After seeding 10 users,
SELECT last_value, is_called FROM users_id_seq; shows last_value as 1, not 10 or higher as expected. This causes the duplocated Id issue.Expected Behavior: The sequence should have been updated to the last inserted id after seeding.
Current Workaround: I manually reset the sequence with
SELECT setval('users_id_seq', (SELECT MAX(id) FROM users));post-seeding to fix the issue.Is there a known issue with how Drizzle handles sequences during bulk seeding, or am I missing something in my setup or seeding approach? Any advice or insights would be greatly appreciated.