Skip to content

Migration 063: Fix sequence reset #884

@vprashrex

Description

@vprashrex

Is your feature request related to a problem?
Migration 063 fails on staging due to a UniqueViolation error caused by the model_config sequence being out of sync with the existing IDs in the database, leading to primary key conflicts.

Describe the solution you'd like

  • Reset the sequence to max(id) before the INSERT using setval(pg_get_serial_sequence(...), MAX(id)).
  • Implement the fix in PR: fix/migration-063-sequence-reset.
Original issue

Describe the bug
A clear and concise description of what the bug is.
Migration 063 (seed stt/tts model_config rows) fails on staging with UniqueViolation: duplicate key value violates unique constraint "model_config_pkey" (Key id=20 already exists). The model_config sequence is behind the actual max id in the DB, so auto-generated ids collide with existing rows.

To Reproduce
Steps to reproduce the behavior:

  1. Have a staging DB where model_config has rows with id >= 20 (sequence not in sync)
  2. Merge PR Model Config: DB-driven validator, seed sarvamai/elevenlabs/google #859 and trigger CD
  3. Alembic runs migration 063
  4. INSERT in step 6 fails with pkey conflict

Expected behavior
A clear and concise description of what you expected to happen.
Migration 063 runs cleanly and seeds all 10 STT/TTS model config rows.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.
Fix: reset sequence to max(id) before the INSERT using setval(pg_get_serial_sequence(...), MAX(id)). PR: fix/migration-063-sequence-reset.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions