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
🔄 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>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/21738
Author: @martional
Created: 2/22/2026
Status: ❌ Closed
Base:
main← Head:fix/drop-tag-id-unique-index📝 Commits (1)
0e4622cfix: 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.idalone that conflicts with the composite primary key(id, user_id). In some upgrade paths or database engines, a unique index onidalone can persist from the original schema and causeUNIQUE constraint failed: tag.id(SQLite) or equivalent errors when multiple users create tags with the same name.Changes
c8d4e5f6a7b8_drop_tag_id_unique_index.pythat inspects the tag table and drops any unique index onidalone if it existsTesting
tag.idis dropped, resolving duplicate-key errors when different users create tags with the same nameChecklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.