Skip to content

Conversation

@jucor
Copy link
Collaborator

@jucor jucor commented Dec 10, 2025

Summary

  • Fix sequence not being reset after pg_restore from prodclone.dump
  • Prevents "duplicate key value violates unique constraint" errors when new users register via OIDC
  • Explicitly calls setval() to ensure sequence starts after highest existing uid

Test plan

  • Run make refresh-prodclone to restore from dump
  • Verify new OIDC users can be created without constraint violations (login with admin@polis.test)

🤖 Generated with Claude Code

When restoring from prodclone.dump, pg_restore does not reset the
users_uid_seq sequence to match the restored data. This may be because
pg_dump with custom format (-Fc) stores sequence states, but our
restore uses --no-owner --no-privileges which could affect how
sequence ownership and thus setval permissions are handled.

This causes "duplicate key value violates unique constraint" errors
when new users try to register via OIDC, as the sequence starts at 1
while UIDs already exist in the restored data.

Explicitly calling setval() after restore ensures the sequence starts
after the highest existing uid, regardless of how the dump was created.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jucor jucor merged commit cd88a29 into compdemocracy:edge Dec 10, 2025
3 checks passed
@jucor jucor deleted the fix-dev-admin-polistest branch December 10, 2025 17:15
ballPointPenguin pushed a commit that referenced this pull request Dec 11, 2025
When restoring from prodclone.dump, pg_restore does not reset the
users_uid_seq sequence to match the restored data. This may be because
pg_dump with custom format (-Fc) stores sequence states, but our
restore uses --no-owner --no-privileges which could affect how
sequence ownership and thus setval permissions are handled.

This causes "duplicate key value violates unique constraint" errors
when new users try to register via OIDC, as the sequence starts at 1
while UIDs already exist in the restored data.

Explicitly calling setval() after restore ensures the sequence starts
after the highest existing uid, regardless of how the dump was created.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants