Skip to content

hotfix: reset model_config sequence before seeding in migration 063#883

Open
vprashrex wants to merge 1 commit into
mainfrom
hotfix/migration-063-sequence-reset
Open

hotfix: reset model_config sequence before seeding in migration 063#883
vprashrex wants to merge 1 commit into
mainfrom
hotfix/migration-063-sequence-reset

Conversation

@vprashrex
Copy link
Copy Markdown
Collaborator

@vprashrex vprashrex commented May 25, 2026

Target issue is #884

Summary

Explain the motivation for making this change. What existing problem does the pull request solve?
Fixes #884. Migration 063 failed on staging because the model_config id sequence was behind the actual max id in the DB. Auto-generated ids during the INSERT collided with existing rows, causing UniqueViolation on model_config_pkey. Fix resets the sequence to max(id) before seeding so new rows get non-conflicting ids.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Summary by CodeRabbit

  • Chores
    • Enhanced database infrastructure with updated schema to support additional model configuration options and data seeding.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 15281a16-abfc-416f-b05b-d819de1bdd5c

📥 Commits

Reviewing files that changed from the base of the PR and between 230fcbb and 75c7986.

📒 Files selected for processing (1)
  • backend/app/alembic/versions/063_seed_stt_tts_model_configs.py

📝 Walkthrough

Walkthrough

Migration 063 is fixed to prevent duplicate key violations by adding a sequence synchronization step. After creating model-config indexes, the migration resets the global.model_config.id sequence to the current maximum ID, ensuring subsequent inserts use non-colliding auto-generated IDs.

Changes

Migration 063: Sequence Synchronization

Layer / File(s) Summary
Sequence reset after index creation
backend/app/alembic/versions/063_seed_stt_tts_model_configs.py
After creating the GIN index on output_modalities, the upgrade adds op.execute() to reset the id sequence to MAX(id) via setval(pg_get_serial_sequence(...), MAX(id)), preventing primary key conflicts during the subsequent model_config insert.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A sequence once lost in the database night,
Found its way back to the ID light,
With setval and MAX, the fix is done,
No more collisions—migration won! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: resetting the model_config sequence before seeding in migration 063, which directly addresses the key issue.
Linked Issues check ✅ Passed The changes implement the fix described in issue #884 by adding a setval() call to reset the sequence to max(id) before INSERT, directly resolving the primary key conflict.
Out of Scope Changes check ✅ Passed All changes are focused on the sequence reset fix for migration 063; no unrelated modifications are present outside the stated objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/migration-063-sequence-reset

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vprashrex vprashrex requested a review from AkhileshNegi May 25, 2026 02:46
@vprashrex vprashrex self-assigned this May 25, 2026
@vprashrex vprashrex added the bug Something isn't working label May 25, 2026
@vprashrex vprashrex linked an issue May 25, 2026 that may be closed by this pull request
@sentry
Copy link
Copy Markdown

sentry Bot commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready-for-review

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Migration 063: Fix sequence reset

1 participant