mirror of
https://github.com/open-webui/open-webui
synced 2024-11-07 00:59:52 +00:00
fix
This commit is contained in:
parent
428fd202c5
commit
1cad157071
@ -50,6 +50,19 @@ def upgrade():
|
|||||||
# delete tag
|
# delete tag
|
||||||
delete_stmt = sa.delete(tag).where(tag.c.id == tag_id)
|
delete_stmt = sa.delete(tag).where(tag.c.id == tag_id)
|
||||||
conn.execute(delete_stmt)
|
conn.execute(delete_stmt)
|
||||||
|
else:
|
||||||
|
# Check if the new_tag_id already exists in the database
|
||||||
|
existing_tag_query = sa.select(tag.c.id).where(tag.c.id == new_tag_id)
|
||||||
|
existing_tag_result = conn.execute(existing_tag_query).fetchone()
|
||||||
|
|
||||||
|
if existing_tag_result:
|
||||||
|
# Handle duplicate case: the new_tag_id already exists
|
||||||
|
print(
|
||||||
|
f"Tag {new_tag_id} already exists. Removing current tag with ID {tag_id} to avoid duplicates."
|
||||||
|
)
|
||||||
|
# Option 1: Delete the current tag if an update to new_tag_id would cause duplication
|
||||||
|
delete_stmt = sa.delete(tag).where(tag.c.id == tag_id)
|
||||||
|
conn.execute(delete_stmt)
|
||||||
else:
|
else:
|
||||||
update_stmt = sa.update(tag).where(tag.c.id == tag_id)
|
update_stmt = sa.update(tag).where(tag.c.id == tag_id)
|
||||||
update_stmt = update_stmt.values(id=new_tag_id)
|
update_stmt = update_stmt.values(id=new_tag_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user