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.
🔄 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>
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/7752
Author: @MadsLang
Created: 12/10/2024
Status: ❌ Closed
Base:
dev← Head:main📝 Commits (1)
3321885add 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
Added
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.