[PR #7752] [CLOSED] Add option to add database schema as env var #8897

Closed
opened 2025-11-11 18:08:58 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/7752
Author: @MadsLang
Created: 12/10/2024
Status: Closed

Base: devHead: main


📝 Commits (1)

  • 3321885 add option to add database schema as env var

📊 Changes

2 files changed (+6 additions, -2 deletions)

View changed files

📝 backend/open_webui/apps/webui/internal/db.py (+4 -2)
📝 backend/open_webui/env.py (+2 -0)

📄 Description

Changelog Entry

Description

  • When using Postgresql as database, there can be conflicts between reserved keywords like "user" and the table names, e.g. "user". I have described this in this issue. To fix this problem, I added the option to set DATABASE_SCHEMA as an environment variable, that sets a default schema to use for all tables for the internal database.

Added

  • The options to use the environment variable DATABASE_SCHEMA. This sets a default schema in the sqlalchemy ORM definition using the MetaData class described here.

Additional information

I have also made a PR updating the docs.


🔄 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/7752 **Author:** [@MadsLang](https://github.com/MadsLang) **Created:** 12/10/2024 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `main` --- ### 📝 Commits (1) - [`3321885`](https://github.com/open-webui/open-webui/commit/332188535e643585f4bba07d9de2328cd0fd5502) add option to add database schema as env var ### 📊 Changes **2 files changed** (+6 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/apps/webui/internal/db.py` (+4 -2) 📝 `backend/open_webui/env.py` (+2 -0) </details> ### 📄 Description # Changelog Entry ### Description - When using Postgresql as database, there can be conflicts between reserved keywords like "user" and the table names, e.g. "user". I have described this in [this issue](https://github.com/open-webui/open-webui/issues/7750). To fix this problem, I added the option to set DATABASE_SCHEMA as an environment variable, that sets a default schema to use for all tables for the internal database. ### Added - The options to use the environment variable DATABASE_SCHEMA. This sets a default schema in the sqlalchemy ORM definition using the MetaData class described [here](https://docs.sqlalchemy.org/en/14/orm/declarative_tables.html#explicit-schema-name-with-declarative-table). ### Additional information I have also made [a PR](https://github.com/open-webui/docs/pull/314) updating the docs. --- <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 2025-11-11 18:08:58 -06: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#8897