[PR #21738] [CLOSED] fix: drop unique index on tag(id) to fix duplicate-key errors #26253

Closed
opened 2026-04-20 06:24:32 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21738
Author: @martional
Created: 2/22/2026
Status: Closed

Base: mainHead: fix/drop-tag-id-unique-index


📝 Commits (1)

  • 0e4622c fix: drop unique index on tag(id) to fix duplicate-key errors

📊 Changes

1 file changed (+53 additions, -0 deletions)

View changed files

backend/open_webui/migrations/versions/c8d4e5f6a7b8_drop_tag_id_unique_index.py (+53 -0)

📄 Description

fix: drop unique index on tag(id) to fix duplicate-key errors

Summary

Fixes #21737

Drops any leftover unique index on tag.id alone that conflicts with the composite primary key (id, user_id). In some upgrade paths or database engines, a unique index on id alone can persist from the original schema and cause UNIQUE constraint failed: tag.id (SQLite) or equivalent errors when multiple users create tags with the same name.

Changes

  • Add migration c8d4e5f6a7b8_drop_tag_id_unique_index.py that inspects the tag table and drops any unique index on id alone if it exists
  • Migration is idempotent and safe: only drops indexes that match the problematic pattern
  • No downgrade (intentional: we don't recreate the problematic index)

Testing

  • Migration runs without error on databases that don't have the problematic index
  • On affected databases, the unique index on tag.id is dropped, resolving duplicate-key errors when different users create tags with the same name

Checklist

  • Follows project coding standards (matches existing migration style)
  • References related issue (#21737)
  • Clear, descriptive commit message

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/21738 **Author:** [@martional](https://github.com/martional) **Created:** 2/22/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/drop-tag-id-unique-index` --- ### 📝 Commits (1) - [`0e4622c`](https://github.com/open-webui/open-webui/commit/0e4622c3ac9003fab496563302c768f6d8d40a49) fix: drop unique index on tag(id) to fix duplicate-key errors ### 📊 Changes **1 file changed** (+53 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `backend/open_webui/migrations/versions/c8d4e5f6a7b8_drop_tag_id_unique_index.py` (+53 -0) </details> ### 📄 Description # fix: drop unique index on tag(id) to fix duplicate-key errors ## Summary Fixes #21737 Drops any leftover unique index on `tag.id` alone that conflicts with the composite primary key `(id, user_id)`. In some upgrade paths or database engines, a unique index on `id` alone can persist from the original schema and cause `UNIQUE constraint failed: tag.id` (SQLite) or equivalent errors when multiple users create tags with the same name. ## Changes - Add migration `c8d4e5f6a7b8_drop_tag_id_unique_index.py` that inspects the tag table and drops any unique index on `id` alone if it exists - Migration is idempotent and safe: only drops indexes that match the problematic pattern - No downgrade (intentional: we don't recreate the problematic index) ## Testing - Migration runs without error on databases that don't have the problematic index - On affected databases, the unique index on `tag.id` is dropped, resolving duplicate-key errors when different users create tags with the same name ## Checklist - [x] Follows project coding standards (matches existing migration style) - [x] References related issue (#21737) - [x] Clear, descriptive commit message --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 06:24:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#26253