mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 14:39:31 -05:00
[PR #22717] [CLOSED] fix: add missing primary key constraints to legacy Peewee tables #81701
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22717
Author: @ryan-pip
Created: 3/16/2026
Status: ❌ Closed
Base:
dev← Head:fix/add-missing-primary-keys📝 Commits (1)
7f7cf8ffix: add missing primary key constraints to legacy Peewee tables📊 Changes
1 file changed (+51 additions, -0 deletions)
View changed files
➕
backend/open_webui/migrations/versions/c3d4e5f6a7b8_add_missing_primary_keys.py(+51 -0)📄 Description
Closes / relates to: https://github.com/open-webui/open-webui/discussions/22716
Description
Tables originally created by the legacy Peewee migration system have only
UNIQUEconstraints on theiridcolumns — notPRIMARY KEYconstraints. When the project migrated to Alembic, the init migration skips tables that already exist, so the PKs were never added.This PR adds a new Alembic migration (
c3d4e5f6a7b8) that retroactively promotes the unique constraint to a primary key for all 7 affected tables.Changelog
Fixed
the legacy Peewee migration system (
chat,chatidtag,file,function,memory,model,tool) were missingPRIMARY KEYconstraints on their
idcolumns. A new Alembic migration(
c3d4e5f6a7b8) retroactively adds the primary key and drops thenow-redundant unique constraint. The migration is idempotent and safe
to run on databases that were already migrated through Alembic.
Checklist
devbranch, notmainupgrade()checks the existing PK constraint before actingdowngrade()removes the PK cleanlyalembic upgrade head→ PKs present, unique constraints removed)📌 CLA
By submitting this pull request, I confirm that my contribution is made under the terms of the project's license and that I have the right to submit it.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.