mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 06:03:26 -05:00
[PR #24197] fix: add idempotency to PostgreSQL migrations to prevent DuplicateTable/UniqueViolation errors #82420
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/24197
Author: @juanpabloequihua
Created: 4/28/2026
Status: 🔄 Open
Base:
dev← Head:fix-postgres-migrations📝 Commits (1)
cf77c47fix: add idempotency to postgres migrations to prevent duplicate key/table errors📊 Changes
6 files changed (+212 additions, -118 deletions)
View changed files
📝
backend/open_webui/migrations/versions/56359461a091_add_calendar_tables.py(+81 -49)📝
backend/open_webui/migrations/versions/a3dd5bedd151_add_tasks_and_summary_to_chat.py(+16 -3)📝
backend/open_webui/migrations/versions/b7c8d9e0f1a2_add_last_read_at_to_chat.py(+8 -3)📝
backend/open_webui/migrations/versions/c1d2e3f4a5b6_add_shared_chat_table.py(+51 -33)📝
backend/open_webui/migrations/versions/d4e5f6a7b8c9_add_automation_tables.py(+49 -29)📝
backend/open_webui/migrations/versions/e1f2a3b4c5d6_add_is_pinned_to_note.py(+7 -1)📄 Description
Description
Adds existence checks (idempotency) for tables, columns, indexes, and grant records across 6 migration files. This prevents migration failures (specifically
psycopg2.errors.UniqueViolationandpsycopg2.errors.DuplicateTable) on PostgreSQL deployments. This is especially critical for large databases (100GB+) or environments where a migration might partially execute and then fail on a subsequent restart.Changelog Entry
Fixed
a3dd5bedd151,d4e5f6a7b8c9,b7c8d9e0f1a2,e1f2a3b4c5d6,c1d2e3f4a5b6, and56359461a091.UniqueViolationinaccess_granttable migration by checking for existing records before insertion.DuplicateTableandDuplicateColumnerrors by usinghas_tableand information_schema checks.Additional Information
Before submitting, make sure you've checked the following:
devbranch. PRs targetingmainwill be immediately closed.devto ensure no unrelated commits (e.g. frommain) are included. Push updates to the existing PR branch instead of closing and reopening.Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.