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 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.
Additional information
I will also make a PR to update the docs.
This change was previously submitted as a PR, but has been rebased and tested.
🔄 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/8510
**Author:** [@MadsLang](https://github.com/MadsLang)
**Created:** 1/13/2025
**Status:** ✅ Merged
**Merged:** 1/13/2025
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `dev` ← **Head:** `main`
---
### 📝 Commits (3)
- [`3321885`](https://github.com/open-webui/open-webui/commit/332188535e643585f4bba07d9de2328cd0fd5502) add option to add database schema as env var
- [`6f1065b`](https://github.com/open-webui/open-webui/commit/6f1065b56aa6630f614925e1afd1bf23f26ec232) Merge branch 'dev' of github.com:open-webui/open-webui
- [`d4a26f8`](https://github.com/open-webui/open-webui/commit/d4a26f80310191993d75545a184bc3ab11f750d4) Merge branch 'open-webui:main' into main
### 📊 Changes
**2 files changed** (+6 additions, -2 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/env.py` (+2 -0)
📝 `backend/open_webui/internal/db.py` (+4 -2)
</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 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 will also make a PR to update the docs.
- This change was previously submitted as [a PR](https://github.com/open-webui/open-webui/pull/7752), but has been rebased and tested.
---
<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/8510
Author: @MadsLang
Created: 1/13/2025
Status: ✅ Merged
Merged: 1/13/2025
Merged by: @tjbck
Base:
dev← Head:main📝 Commits (3)
3321885add option to add database schema as env var6f1065bMerge branch 'dev' of github.com:open-webui/open-webuid4a26f8Merge branch 'open-webui:main' into main📊 Changes
2 files changed (+6 additions, -2 deletions)
View changed files
📝
backend/open_webui/env.py(+2 -0)📝
backend/open_webui/internal/db.py(+4 -2)📄 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 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.
Additional information
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.