[PR #23405] [CLOSED] feat: Add support for using mariadb for the backend database #50230

Closed
opened 2026-04-30 02:51:29 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/23405
Author: @seulement55
Created: 4/4/2026
Status: Closed

Base: devHead: feat/add-support-mariaDB-capabilities


📝 Commits (1)

  • 217bf40 feat: Add support for using mariadb for the backend database

📊 Changes

18 files changed (+361 additions, -43 deletions)

View changed files

📝 backend/open_webui/internal/db.py (+2 -2)
📝 backend/open_webui/internal/migrations/007_add_user_last_active_at.py (+12 -2)
📝 backend/open_webui/internal/migrations/009_add_models.py (+6 -3)
📝 backend/open_webui/internal/migrations/012_add_tools.py (+5 -2)
📝 backend/open_webui/internal/migrations/014_add_files.py (+5 -2)
📝 backend/open_webui/internal/migrations/015_add_functions.py (+5 -2)
backend/open_webui/internal/utils.py (+12 -0)
📝 backend/open_webui/internal/wrappers.py (+39 -2)
📝 backend/open_webui/migrations/README (+11 -0)
📝 backend/open_webui/migrations/env.py (+128 -0)
📝 backend/open_webui/migrations/util.py (+38 -1)
📝 backend/open_webui/migrations/versions/38d63c18f30f_add_oauth_session_table.py (+2 -1)
📝 backend/open_webui/migrations/versions/8452d01d26d7_add_chat_message_table.py (+7 -5)
📝 backend/open_webui/migrations/versions/b10670c03dd5_update_user_table.py (+13 -6)
📝 backend/open_webui/migrations/versions/c69f45358db4_add_folder_table.py (+3 -2)
📝 backend/open_webui/migrations/versions/d4e5f6a7b8c9_add_automation_tables.py (+7 -5)
📝 backend/open_webui/migrations/versions/f1e2d3c4b5a6_add_access_grant_table.py (+65 -7)
📝 backend/requirements.txt (+1 -1)

📄 Description

Pull Request Checklist

  • Target branch: Verify that the pull request targets the dev branch. PRs targeting main will be immediately closed.
  • Description: Provide a concise description of the changes made in this pull request down below.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Add docs in Open WebUI Docs Repository. Document user-facing behavior, environment variables, public APIs/interfaces, or deployment steps.
  • Dependencies: Are there any new or upgraded dependencies? If so, explain why, update the changelog/docs, and include any compatibility notes. Actually run the code/function that uses updated library to ensure it doesn't crash.
  • Testing: Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Include reproducible steps to demonstrate the issue before the fix. Test edge cases (URL encoding, HTML entities, types). Take this as an opportunity to make screenshots of the feature/fix and include them in the PR description.
  • Agentic AI Code: Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review AND manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR.
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Design & Architecture: Prefer smart defaults over adding new settings; use local state for ephemeral UI logic. Open a Discussion for major architectural or UX changes.
  • Git Hygiene: Keep PRs atomic (one logical change). Clean up commits and rebase on dev to ensure no unrelated commits (e.g. from main) are included. Push updates to the existing PR branch instead of closing and reopening.
  • Title Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • feat: Introduces a new feature or enhancement to the codebase

Description

Open-WebUI currently supports SQLite and PostgreSQL as primary databases. This PR adds MariaDB as a supported primary backend database, allowing Open-WebUI to run with MariaDB for application data, migrations, and runtime persistence.

My main motivation for proposing this change is operational simplicity: Open-WebUI already supports MariaDB Vector as a vector database backend, so adding MariaDB as the primary database allows users to deploy both the main application data and vector storage on a single database system instead of operating multiple database technologies side-by-side.

For users who are already committed to MariaDB infrastructure, this means:

  • fewer moving parts,
  • simpler deployment and backup strategy,
  • more consistent operational tooling,
  • and a lower barrier to adopting Open-WebUI in environments where PostgreSQL is not already standard.

This PR is designed as an opt-in compatibility expansion rather than a database-layer redesign. Existing SQLite and PostgreSQL users are unaffected.

This work addresses the request to support MariaDB as a main database backend (see discussion #22803).

Scope of the change

This PR adds MariaDB support for the primary backend database by:

  • enabling MariaDB/MySQL-compatible Peewee connection handling,
  • normalizing supported SQLAlchemy-style database URLs for Peewee migration/runtime compatibility,
  • adding reconnect behavior for MySQL/MariaDB in the same style as PostgreSQL,
  • handling migration edge cases that are not directly compatible with MariaDB/MySQL,
  • and adding the required MariaDB dependency for runtime and migration flows.

This PR is intentionally limited to MariaDB as the primary backend database.

Design notes

This change is intended to stay aligned with the current architecture:

  • it does not introduce a new persistence model,
  • it does not change any default database choice,
  • it does not add UI-level complexity,
  • it is only activated when users explicitly configure a MariaDB DATABASE_URL.

The implementation follows the same overall connection/migration pattern already used for existing primary database backends.

Dependencies

New dependency added:

  • mariadb Python driver

Rationale:

MariaDB primary DB support uses the preferred mariadb+mariadbconnector://... URL scheme, which requires the official MariaDB Connector/Python driver. PyMySQL remains available as a compatibility fallback for mysql+pymysql://....

Compatibility notes:

  • MariaDB support is opt-in and only affects deployments configured with a MariaDB DATABASE_URL.
  • Existing SQLite and PostgreSQL setups should continue to work unchanged.

Manual tests

Build the Docker image from this branch:

$ docker build -f Dockerfile -t open-webui:0.9.0-dev .

Both test runs below used a fresh empty database before startup.

MariaDB primary DB + MariaDB vector test

Start Open-WebUI against MariaDB

docker run -d \
  --network host \
  -e OLLAMA_BASE_URL="http://ollama-host.com:11434" \
  -e AIOHTTP_CLIENT_TIMEOUT=3600 \
  \
  -e ENABLE_PERSISTENT_CONFIG=False \
  -e DEFAULT_MODEL_PARAMS='{"num_ctx":32768,"temperature":0.1,"top_p":0.9}' \
  \
  -e RAG_EMBEDDING_ENGINE=ollama \
  -e RAG_OLLAMA_BASE_URL="http://ollama-host.com:11434" \
  -e RAG_EMBEDDING_MODEL=nomic-embed-text \
  -e RAG_EMBEDDING_BATCH_SIZE=64 \
  -e RAG_TEXT_SPLITTER=token \
  -e RAG_SYSTEM_CONTEXT=True \
  -e RAG_TOP_K=10 \
  -e RAG_TOP_K_RERANKER=10 \
  \
  -e CHUNK_SIZE=1024 \
  -e CHUNK_OVERLAP=128 \
  -e CHUNK_MIN_SIZE_TARGET=640 \
  -e ENABLE_ASYNC_EMBEDDING=true \
  -e RAG_EMBEDDING_CONCURRENT_REQUESTS=8 \
  -e ENABLE_RAG_HYBRID_SEARCH=true \
  \
  -e DATABASE_URL="mariadb+mariadbconnector://app:app@127.0.0.1:3306/openwebui" \
  -e VECTOR_DB="mariadb-vector" \
  -e MARIADB_VECTOR_DB_URL="mariadb+mariadbconnector://app:app@127.0.0.1:3306/openwebui" \
  -e MARIADB_VECTOR_INITIALIZE_MAX_VECTOR_LENGTH=768 \
  -e MARIADB_VECTOR_DISTANCE_STRATEGY=cosine \
  -e MARIADB_VECTOR_INDEX_M=12 \
  \
  -v open-webui:/app/backend/data \
  --name open-webui \
  --restart always \
  open-webui:0.9.0-dev

There are no migration/runtime errors:

server@ai:[debug_open-webui] [] $ docker logs -f open-webui
Loading WEBUI_SECRET_KEY from file, not provided as an environment variable.
Generating WEBUI_SECRET_KEY
Loading WEBUI_SECRET_KEY from .webui_secret_key
INFO  [alembic.runtime.migration] Context impl MariaDBImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 7e5b5dc7342b, init
INFO  [alembic.runtime.migration] Running upgrade 7e5b5dc7342b -> ca81bd47c050, Add config table
INFO  [alembic.runtime.migration] Running upgrade ca81bd47c050 -> c0fbf31ca0db, Update file table
INFO  [alembic.runtime.migration] Running upgrade c0fbf31ca0db -> 6a39f3d8e55c, Add knowledge table
Creating knowledge table
Migrating data from document table to knowledge table
INFO  [alembic.runtime.migration] Running upgrade 6a39f3d8e55c -> 242a2047eae0, Update chat table
Converting 'chat' column to JSON
Renaming 'chat' column to 'old_chat'
Adding new 'chat' column of type JSON
Dropping 'old_chat' column
INFO  [alembic.runtime.migration] Running upgrade 242a2047eae0 -> 1af9b942657b, Migrate tags
INFO  [alembic.runtime.migration] Running upgrade 1af9b942657b -> 3ab32c4b8f59, Update tags
Primary Key: {'name': None, 'constrained_columns': []}
Unique Constraints: [{'name': 'tag_id', 'column_names': ['id'], 'duplicates_index': 'tag_id'}, {'name': 'uq_id_user_id', 'column_names': ['id', 'user_id'], 'duplicates_index': 'uq_id_user_id'}]
Indexes: [{'name': 'tag_id', 'column_names': ['id'], 'unique': True, 'type': 'UNIQUE'}, {'name': 'uq_id_user_id', 'column_names': ['id', 'user_id'], 'unique': True, 'type': 'UNIQUE'}]
Creating new primary key with 'id' and 'user_id'.
Dropping unique constraint: uq_id_user_id
INFO  [alembic.runtime.migration] Running upgrade 3ab32c4b8f59 -> c69f45358db4, Add folder table
INFO  [alembic.runtime.migration] Running upgrade c69f45358db4 -> c29facfe716b, Update file table path
INFO  [alembic.runtime.migration] Running upgrade c29facfe716b -> af906e964978, Add feedback table
INFO  [alembic.runtime.migration] Running upgrade af906e964978 -> 4ace53fd72c8, Update folder table and change DateTime to BigInteger for timestamp fields
INFO  [alembic.runtime.migration] Running upgrade 4ace53fd72c8 -> 922e7a387820, Add group table
INFO  [alembic.runtime.migration] Running upgrade 922e7a387820 -> 57c599a3cb57, Add channel table
INFO  [alembic.runtime.migration] Running upgrade 57c599a3cb57 -> 7826ab40b532, Update file table
INFO  [alembic.runtime.migration] Running upgrade 7826ab40b532 -> 3781e22d8b01, Update message & channel tables
INFO  [alembic.runtime.migration] Running upgrade 3781e22d8b01 -> 9f0c9cd09105, Add note table
INFO  [alembic.runtime.migration] Running upgrade 9f0c9cd09105 -> d31026856c01, Update folder table data
INFO  [alembic.runtime.migration] Running upgrade d31026856c01 -> 018012973d35, Add indexes
INFO  [alembic.runtime.migration] Running upgrade 018012973d35 -> 3af16a1c9fb6, update user table
INFO  [alembic.runtime.migration] Running upgrade 3af16a1c9fb6 -> 38d63c18f30f, Add oauth_session table
INFO  [alembic.runtime.migration] Running upgrade 38d63c18f30f -> a5c220713937, Add reply_to_id column to message
INFO  [alembic.runtime.migration] Running upgrade a5c220713937 -> 37f288994c47, add_group_member_table
[]
INFO  [alembic.runtime.migration] Running upgrade 37f288994c47 -> 2f1211949ecc, Update messages and channel member table
INFO  [alembic.runtime.migration] Running upgrade 2f1211949ecc -> b10670c03dd5, Update user table
INFO  [alembic.runtime.migration] Running upgrade b10670c03dd5 -> 90ef40d4714e, Update channel and channel members table
INFO  [alembic.runtime.migration] Running upgrade 90ef40d4714e -> 3e0e00844bb0, Add knowledge_file table
INFO  [alembic.runtime.migration] Running upgrade 3e0e00844bb0 -> 6283dc0e4d8d, Add channel file table
INFO  [alembic.runtime.migration] Running upgrade 6283dc0e4d8d -> 81cc2ce44d79, Update channel file and knowledge table
INFO  [alembic.runtime.migration] Running upgrade 81cc2ce44d79 -> c440947495f3, Add chat_file table
INFO  [alembic.runtime.migration] Running upgrade c440947495f3 -> 374d2f66af06, Add prompt history table
INFO  [alembic.runtime.migration] Running upgrade 374d2f66af06 -> 8452d01d26d7, Add chat_message table
INFO  [alembic.runtime.migration] Running upgrade 8452d01d26d7 -> f1e2d3c4b5a6, Add access_grant table
INFO  [alembic.runtime.migration] Running upgrade f1e2d3c4b5a6 -> a1b2c3d4e5f6, Add skill table
INFO  [alembic.runtime.migration] Running upgrade a1b2c3d4e5f6 -> b2c3d4e5f6a7, add scim column to user table
INFO  [alembic.runtime.migration] Running upgrade b2c3d4e5f6a7 -> a3dd5bedd151, Add tasks and summary columns to chat table
INFO  [alembic.runtime.migration] Running upgrade a3dd5bedd151 -> d4e5f6a7b8c9, add automation tables
INFO  [alembic.runtime.migration] Running upgrade d4e5f6a7b8c9 -> b7c8d9e0f1a2, add last_read_at to chat
WARNI [open_webui.env] 

WARNING: CORS_ALLOW_ORIGIN IS SET TO '*' - NOT RECOMMENDED FOR PRODUCTION DEPLOYMENTS.

WARNI [langchain_community.utils.user_agent] USER_AGENT environment variable not set, consider setting it to identify your requests.

 ██████╗ ██████╗ ███████╗███╗   ██╗    ██╗    ██╗███████╗██████╗ ██╗   ██╗██╗
██╔═══██╗██╔══██╗██╔════╝████╗  ██║    ██║    ██║██╔════╝██╔══██╗██║   ██║██║
██║   ██║██████╔╝█████╗  ██╔██╗ ██║    ██║ █╗ ██║█████╗  ██████╔╝██║   ██║██║
██║   ██║██╔═══╝ ██╔══╝  ██║╚██╗██║    ██║███╗██║██╔══╝  ██╔══██╗██║   ██║██║
╚██████╔╝██║     ███████╗██║ ╚████║    ╚███╔███╔╝███████╗██████╔╝╚██████╔╝██║
 ╚═════╝ ╚═╝     ╚══════╝╚═╝  ╚═══╝     ╚══╝╚══╝ ╚══════╝╚═════╝  ╚═════╝ ╚═╝


v0.8.12 - building the best AI user interface.

https://github.com/open-webui/open-webui

INFO:     Started server process [1]
INFO:     Waiting for application startup.
2026-04-04 17:47:40.165 | INFO     | open_webui.utils.logger:start_logger:192 - GLOBAL_LOG_LEVEL: INFO
2026-04-04 17:47:40.166 | INFO     | open_webui.main:lifespan:636 - Installing external dependencies of functions and tools...
2026-04-04 17:47:40.187 | INFO     | open_webui.utils.plugin:install_frontmatter_requirements:404 - No requirements found in frontmatter.
2026-04-04 17:47:40.187 | INFO     | open_webui.utils.automations:automation_worker_loop:106 - Automation worker started (poll interval: 10s)

Verify migration-created tables exist

$ mariadb -uapp -papp -D openwebui -e "
SELECT version_num FROM alembic_version;
SHOW TABLES LIKE 'chat_message';
SHOW TABLES LIKE 'access_grant';
SHOW TABLES LIKE 'automation';
SHOW TABLES LIKE 'automation_run';
"

+--------------+
| version_num  |
+--------------+
| b7c8d9e0f1a2 |
+--------------+
+------------------------------------+
| Tables_in_openwebui (chat_message) |
+------------------------------------+
| chat_message                       |
+------------------------------------+
+------------------------------------+
| Tables_in_openwebui (access_grant) |
+------------------------------------+
| access_grant                       |
+------------------------------------+
+----------------------------------+
| Tables_in_openwebui (automation) |
+----------------------------------+
| automation                       |
+----------------------------------+
+--------------------------------------+
| Tables_in_openwebui (automation_run) |
+--------------------------------------+
| automation_run                       |
+--------------------------------------+

Check important indexes were created

$ mariadb -uapp -papp -D openwebui -e "
SHOW INDEX FROM chat_message;
SHOW INDEX FROM access_grant;
SHOW INDEX FROM automation_run;
"

+--------------+------------+--------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
| Table        | Non_unique | Key_name                       | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Ignored |
+--------------+------------+--------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
| chat_message |          0 | PRIMARY                        |            1 | id          | A         |           2 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| chat_message |          1 | ix_chat_message_user_id        |            1 | user_id     | A         |           1 |     NULL | NULL   | YES  | BTREE      |         |               | NO      |
| chat_message |          1 | ix_chat_message_model_id       |            1 | model_id    | A         |           2 |     NULL | NULL   | YES  | BTREE      |         |               | NO      |
| chat_message |          1 | ix_chat_message_chat_id        |            1 | chat_id     | A         |           1 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| chat_message |          1 | ix_chat_message_created_at     |            1 | created_at  | A         |           1 |     NULL | NULL   | YES  | BTREE      |         |               | NO      |
| chat_message |          1 | chat_message_chat_parent_idx   |            1 | chat_id     | A         |           1 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| chat_message |          1 | chat_message_chat_parent_idx   |            2 | parent_id   | A         |           2 |     NULL | NULL   | YES  | BTREE      |         |               | NO      |
| chat_message |          1 | chat_message_model_created_idx |            1 | model_id    | A         |           2 |     NULL | NULL   | YES  | BTREE      |         |               | NO      |
| chat_message |          1 | chat_message_model_created_idx |            2 | created_at  | A         |           2 |     NULL | NULL   | YES  | BTREE      |         |               | NO      |
| chat_message |          1 | chat_message_user_created_idx  |            1 | user_id     | A         |           1 |     NULL | NULL   | YES  | BTREE      |         |               | NO      |
| chat_message |          1 | chat_message_user_created_idx  |            2 | created_at  | A         |           1 |     NULL | NULL   | YES  | BTREE      |         |               | NO      |
+--------------+------------+--------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
+--------------+------------+----------------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
| Table        | Non_unique | Key_name                   | Seq_in_index | Column_name    | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Ignored |
+--------------+------------+----------------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
| access_grant |          0 | PRIMARY                    |            1 | id             | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| access_grant |          0 | uq_access_grant_grant      |            1 | resource_type  | A         |           0 |     NULL | NULL   |      | HASH       |         |               | NO      |
| access_grant |          0 | uq_access_grant_grant      |            2 | resource_id    | A         |           0 |     NULL | NULL   |      | HASH       |         |               | NO      |
| access_grant |          0 | uq_access_grant_grant      |            3 | principal_type | A         |           0 |     NULL | NULL   |      | HASH       |         |               | NO      |
| access_grant |          0 | uq_access_grant_grant      |            4 | principal_id   | A         |           0 |     NULL | NULL   |      | HASH       |         |               | NO      |
| access_grant |          0 | uq_access_grant_grant      |            5 | permission     | A         |           0 |     NULL | NULL   |      | HASH       |         |               | NO      |
| access_grant |          1 | idx_access_grant_resource  |            1 | resource_type  | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| access_grant |          1 | idx_access_grant_resource  |            2 | resource_id    | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| access_grant |          1 | idx_access_grant_principal |            1 | principal_type | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| access_grant |          1 | idx_access_grant_principal |            2 | principal_id   | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | NO      |
+--------------+------------+----------------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
+----------------+------------+---------------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
| Table          | Non_unique | Key_name                        | Seq_in_index | Column_name   | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Ignored |
+----------------+------------+---------------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+
| automation_run |          0 | PRIMARY                         |            1 | id            | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | NO      |
| automation_run |          1 | ix_automation_run_automation_id |            1 | automation_id | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | NO      |
+----------------+------------+---------------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+

Verify DB rows after manual actions

$ mariadb -uapp -papp -D openwebui -e "
SELECT COUNT(*) AS users_count FROM \`user\`;
SELECT COUNT(*) AS file_count FROM file;
SELECT COUNT(*) AS knowledge_count FROM knowledge;
SELECT COUNT(*) AS knowledge_file_count FROM knowledge_file;
"

+-------------+
| users_count |
+-------------+
|           1 |
+-------------+
+------------+
| file_count |
+------------+
|        216 |
+------------+
+-----------------+
| knowledge_count |
+-----------------+
|               1 |
+-----------------+
+----------------------+
| knowledge_file_count |
+----------------------+
|                  216 |
+----------------------+

Screenshots

image

PostgesSQL primary DB + pgvector test

Start Open-WebUI against PostgesSQL

docker run -d \
  --network host \
  --name open-webui-pg \
  -e PORT=8081 \
  --restart always \
  -e OLLAMA_BASE_URL="http://ollama-host.com:11434" \
  -e AIOHTTP_CLIENT_TIMEOUT=3600 \
  \
  -e ENABLE_PERSISTENT_CONFIG=False \
  -e DEFAULT_MODEL_PARAMS='{"num_ctx":32768,"temperature":0.1,"top_p":0.9}' \
  \
  -e RAG_EMBEDDING_ENGINE=ollama \
  -e RAG_OLLAMA_BASE_URL="http://ollama-host.com:11434" \
  -e RAG_EMBEDDING_MODEL=nomic-embed-text \
  -e RAG_EMBEDDING_BATCH_SIZE=64 \
  -e RAG_TEXT_SPLITTER=token \
  -e RAG_SYSTEM_CONTEXT=True \
  -e RAG_TOP_K=10 \
  -e RAG_TOP_K_RERANKER=10 \
  \
  -e CHUNK_SIZE=1024 \
  -e CHUNK_OVERLAP=128 \
  -e CHUNK_MIN_SIZE_TARGET=640 \
  -e ENABLE_ASYNC_EMBEDDING=true \
  -e RAG_EMBEDDING_CONCURRENT_REQUESTS=8 \
  -e ENABLE_RAG_HYBRID_SEARCH=true \
  \
  -e DATABASE_URL="postgres://app_pg:app_pg@127.0.0.1:5432/openwebui_pg" \
  -e VECTOR_DB="pgvector" \
  -e PGVECTOR_DB_URL="postgresql+psycopg2://app_pg:app_pg@127.0.0.1:5432/openwebui_pg" \
  -e PGVECTOR_INITIALIZE_MAX_VECTOR_LENGTH=768 \
  -e PGVECTOR_CREATE_EXTENSION=true \
  -e PGVECTOR_PGCRYPTO=false \
  -v open-webui-pg:/app/backend/data \
  open-webui:0.9.0-dev

There are no migration/runtime errors:

server@ai:[debug_open-webui] [] $ docker logs -f open-webui-pg
Loading WEBUI_SECRET_KEY from file, not provided as an environment variable.
Generating WEBUI_SECRET_KEY
Loading WEBUI_SECRET_KEY from .webui_secret_key
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 7e5b5dc7342b, init
INFO  [alembic.runtime.migration] Running upgrade 7e5b5dc7342b -> ca81bd47c050, Add config table
INFO  [alembic.runtime.migration] Running upgrade ca81bd47c050 -> c0fbf31ca0db, Update file table
Creating knowledge table
INFO  [alembic.runtime.migration] Running upgrade c0fbf31ca0db -> 6a39f3d8e55c, Add knowledge table
Migrating data from document table to knowledge table
INFO  [alembic.runtime.migration] Running upgrade 6a39f3d8e55c -> 242a2047eae0, Update chat table
Converting 'chat' column to JSON
Renaming 'chat' column to 'old_chat'
Adding new 'chat' column of type JSON
Dropping 'old_chat' column
INFO  [alembic.runtime.migration] Running upgrade 242a2047eae0 -> 1af9b942657b, Migrate tags
INFO  [alembic.runtime.migration] Running upgrade 1af9b942657b -> 3ab32c4b8f59, Update tags
Primary Key: {'name': None, 'constrained_columns': []}
Unique Constraints: [{'column_names': ['id', 'user_id'], 'name': 'uq_id_user_id', 'comment': None, 'dialect_options': {'postgresql_include': [], 'postgresql_nulls_not_distinct': False}}]
Indexes: [{'name': 'tag_id', 'unique': True, 'column_names': ['id'], 'include_columns': [], 'dialect_options': {'postgresql_include': []}}, {'name': 'uq_id_user_id', 'unique': True, 'column_names': ['id', 'user_id'], 'duplicates_constraint': 'uq_id_user_id', 'include_columns': [], 'dialect_options': {'postgresql_include': []}}]
Creating new primary key with 'id' and 'user_id'.
Dropping unique constraint: uq_id_user_id
Dropping unique index: tag_id
INFO  [alembic.runtime.migration] Running upgrade 3ab32c4b8f59 -> c69f45358db4, Add folder table
INFO  [alembic.runtime.migration] Running upgrade c69f45358db4 -> c29facfe716b, Update file table path
INFO  [alembic.runtime.migration] Running upgrade c29facfe716b -> af906e964978, Add feedback table
INFO  [alembic.runtime.migration] Running upgrade af906e964978 -> 4ace53fd72c8, Update folder table and change DateTime to BigInteger for timestamp fields
INFO  [alembic.runtime.migration] Running upgrade 4ace53fd72c8 -> 922e7a387820, Add group table
INFO  [alembic.runtime.migration] Running upgrade 922e7a387820 -> 57c599a3cb57, Add channel table
INFO  [alembic.runtime.migration] Running upgrade 57c599a3cb57 -> 7826ab40b532, Update file table
INFO  [alembic.runtime.migration] Running upgrade 7826ab40b532 -> 3781e22d8b01, Update message & channel tables
INFO  [alembic.runtime.migration] Running upgrade 3781e22d8b01 -> 9f0c9cd09105, Add note table
INFO  [alembic.runtime.migration] Running upgrade 9f0c9cd09105 -> d31026856c01, Update folder table data
INFO  [alembic.runtime.migration] Running upgrade d31026856c01 -> 018012973d35, Add indexes
INFO  [alembic.runtime.migration] Running upgrade 018012973d35 -> 3af16a1c9fb6, update user table
INFO  [alembic.runtime.migration] Running upgrade 3af16a1c9fb6 -> 38d63c18f30f, Add oauth_session table
INFO  [alembic.runtime.migration] Running upgrade 38d63c18f30f -> a5c220713937, Add reply_to_id column to message
INFO  [alembic.runtime.migration] Running upgrade a5c220713937 -> 37f288994c47, add_group_member_table
[]
INFO  [alembic.runtime.migration] Running upgrade 37f288994c47 -> 2f1211949ecc, Update messages and channel member table
INFO  [alembic.runtime.migration] Running upgrade 2f1211949ecc -> b10670c03dd5, Update user table
INFO  [alembic.runtime.migration] Running upgrade b10670c03dd5 -> 90ef40d4714e, Update channel and channel members table
INFO  [alembic.runtime.migration] Running upgrade 90ef40d4714e -> 3e0e00844bb0, Add knowledge_file table
INFO  [alembic.runtime.migration] Running upgrade 3e0e00844bb0 -> 6283dc0e4d8d, Add channel file table
INFO  [alembic.runtime.migration] Running upgrade 6283dc0e4d8d -> 81cc2ce44d79, Update channel file and knowledge table
INFO  [alembic.runtime.migration] Running upgrade 81cc2ce44d79 -> c440947495f3, Add chat_file table
INFO  [alembic.runtime.migration] Running upgrade c440947495f3 -> 374d2f66af06, Add prompt history table
INFO  [alembic.runtime.migration] Running upgrade 374d2f66af06 -> 8452d01d26d7, Add chat_message table
INFO  [alembic.runtime.migration] Running upgrade 8452d01d26d7 -> f1e2d3c4b5a6, Add access_grant table
INFO  [alembic.runtime.migration] Running upgrade f1e2d3c4b5a6 -> a1b2c3d4e5f6, Add skill table
INFO  [alembic.runtime.migration] Running upgrade a1b2c3d4e5f6 -> b2c3d4e5f6a7, add scim column to user table
INFO  [alembic.runtime.migration] Running upgrade b2c3d4e5f6a7 -> a3dd5bedd151, Add tasks and summary columns to chat table
INFO  [alembic.runtime.migration] Running upgrade a3dd5bedd151 -> d4e5f6a7b8c9, add automation tables
INFO  [alembic.runtime.migration] Running upgrade d4e5f6a7b8c9 -> b7c8d9e0f1a2, add last_read_at to chat
WARNI [open_webui.env] 

WARNING: CORS_ALLOW_ORIGIN IS SET TO '*' - NOT RECOMMENDED FOR PRODUCTION DEPLOYMENTS.

WARNI [langchain_community.utils.user_agent] USER_AGENT environment variable not set, consider setting it to identify your requests.

 ██████╗ ██████╗ ███████╗███╗   ██╗    ██╗    ██╗███████╗██████╗ ██╗   ██╗██╗
██╔═══██╗██╔══██╗██╔════╝████╗  ██║    ██║    ██║██╔════╝██╔══██╗██║   ██║██║
██║   ██║██████╔╝█████╗  ██╔██╗ ██║    ██║ █╗ ██║█████╗  ██████╔╝██║   ██║██║
██║   ██║██╔═══╝ ██╔══╝  ██║╚██╗██║    ██║███╗██║██╔══╝  ██╔══██╗██║   ██║██║
╚██████╔╝██║     ███████╗██║ ╚████║    ╚███╔███╔╝███████╗██████╔╝╚██████╔╝██║
 ╚═════╝ ╚═╝     ╚══════╝╚═╝  ╚═══╝     ╚══╝╚══╝ ╚══════╝╚═════╝  ╚═════╝ ╚═╝


v0.8.12 - building the best AI user interface.

https://github.com/open-webui/open-webui

INFO:     Started server process [1]
INFO:     Waiting for application startup.
2026-04-04 17:55:43.851 | INFO     | open_webui.utils.logger:start_logger:192 - GLOBAL_LOG_LEVEL: INFO
2026-04-04 17:55:43.851 | INFO     | open_webui.main:lifespan:636 - Installing external dependencies of functions and tools...
2026-04-04 17:55:43.873 | INFO     | open_webui.utils.plugin:install_frontmatter_requirements:404 - No requirements found in frontmatter.
2026-04-04 17:55:43.873 | INFO     | open_webui.utils.automations:automation_worker_loop:106 - Automation worker started (poll interval: 10s)

Verify migration-created tables exist

$ PGPASSWORD=app_pg psql -h 127.0.0.1 -U app_pg -d openwebui_pg -c "
SELECT version_num FROM alembic_version;
SELECT tablename FROM pg_tables 
WHERE tablename IN ('chat_message','access_grant','automation','automation_run');
"

 version_num  
--------------
 b7c8d9e0f1a2
(1 row)

   tablename    
----------------
 automation
 automation_run
 chat_message
 access_grant
(4 rows)

Verify DB rows after manual actions

$ PGPASSWORD=app_pg psql -h 127.0.0.1 -U app_pg -d openwebui_pg -c '
SELECT COUNT(*) AS users_count FROM "user";
SELECT COUNT(*) AS file_count FROM file;
SELECT COUNT(*) AS knowledge_count FROM knowledge;
SELECT COUNT(*) AS knowledge_file_count FROM knowledge_file;
'

 users_count 
-------------
           1
(1 row)

 file_count 
------------
        216
(1 row)

 knowledge_count 
-----------------
               1
(1 row)

 knowledge_file_count 
----------------------
                  216
(1 row)

Screenshots

image

Observed outcome

  • Fresh bootstrap succeeded on MariaDB
  • Fresh bootstrap succeeded on PostgreSQL
  • alembic_version reached head on both
  • chat_message, access_grant, automation, automation_run tables created successfully
  • Admin signup/login worked
  • Knowledge file upload worked
  • Persisted rows verified in DB

Documentation


Changelog Entry

Description

  • Add MariaDB as a supported primary database backend so Open-WebUI can run its main application data on MariaDB, including deployments that also use MariaDB Vector for embeddings.

Added

  • Added MariaDB support for the primary backend database.

Changed

  • Updated database connection and migration compatibility logic to support MariaDB-backed deployments.

Additional Information

  • Open-WebUI already supports mariadb-vector on the vector database side; this PR complements that by enabling MariaDB for the primary database as well.
  • The primary value of this change is single-database-system deployment for users standardized on MariaDB.
  • This PR is intentionally scoped to one logical change: MariaDB as a primary backend database.

Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 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/23405 **Author:** [@seulement55](https://github.com/seulement55) **Created:** 4/4/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feat/add-support-mariaDB-capabilities` --- ### 📝 Commits (1) - [`217bf40`](https://github.com/open-webui/open-webui/commit/217bf4040236323ec3e610ff9ae2f041594336b6) feat: Add support for using mariadb for the backend database ### 📊 Changes **18 files changed** (+361 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/internal/db.py` (+2 -2) 📝 `backend/open_webui/internal/migrations/007_add_user_last_active_at.py` (+12 -2) 📝 `backend/open_webui/internal/migrations/009_add_models.py` (+6 -3) 📝 `backend/open_webui/internal/migrations/012_add_tools.py` (+5 -2) 📝 `backend/open_webui/internal/migrations/014_add_files.py` (+5 -2) 📝 `backend/open_webui/internal/migrations/015_add_functions.py` (+5 -2) ➕ `backend/open_webui/internal/utils.py` (+12 -0) 📝 `backend/open_webui/internal/wrappers.py` (+39 -2) 📝 `backend/open_webui/migrations/README` (+11 -0) 📝 `backend/open_webui/migrations/env.py` (+128 -0) 📝 `backend/open_webui/migrations/util.py` (+38 -1) 📝 `backend/open_webui/migrations/versions/38d63c18f30f_add_oauth_session_table.py` (+2 -1) 📝 `backend/open_webui/migrations/versions/8452d01d26d7_add_chat_message_table.py` (+7 -5) 📝 `backend/open_webui/migrations/versions/b10670c03dd5_update_user_table.py` (+13 -6) 📝 `backend/open_webui/migrations/versions/c69f45358db4_add_folder_table.py` (+3 -2) 📝 `backend/open_webui/migrations/versions/d4e5f6a7b8c9_add_automation_tables.py` (+7 -5) 📝 `backend/open_webui/migrations/versions/f1e2d3c4b5a6_add_access_grant_table.py` (+65 -7) 📝 `backend/requirements.txt` (+1 -1) </details> ### 📄 Description <!-- ⚠️ CRITICAL CHECKS FOR CONTRIBUTORS (READ, DON'T DELETE) ⚠️ 1. Target the `dev` branch. PRs targeting `main` will be automatically closed. 2. Do NOT delete the CLA section at the bottom. It is required for the bot to accept your PR. --> # Pull Request Checklist - [x] **Target branch:** Verify that the pull request targets the `dev` branch. **PRs targeting `main` will be immediately closed.** - [x] **Description:** Provide a concise description of the changes made in this pull request down below. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** Add docs in [Open WebUI Docs Repository](https://github.com/open-webui/docs). Document user-facing behavior, environment variables, public APIs/interfaces, or deployment steps. - [x] **Dependencies:** Are there any new or upgraded dependencies? If so, explain why, update the changelog/docs, and include any compatibility notes. Actually run the code/function that uses updated library to ensure it doesn't crash. - [x] **Testing:** Perform manual tests to **verify the implemented fix/feature works as intended AND does not break any other functionality**. Include reproducible steps to demonstrate the issue before the fix. Test edge cases (URL encoding, HTML entities, types). Take this as an opportunity to **make screenshots of the feature/fix and include them in the PR description**. - [x] **Agentic AI Code:** Confirm this Pull Request is **not written by any AI Agent** or has at least **gone through additional human review AND manual testing**. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR. - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Design & Architecture:** Prefer smart defaults over adding new settings; use local state for ephemeral UI logic. Open a Discussion for major architectural or UX changes. - [x] **Git Hygiene:** Keep PRs atomic (one logical change). Clean up commits and rebase on `dev` to ensure no unrelated commits (e.g. from `main`) are included. Push updates to the existing PR branch instead of closing and reopening. - [x] **Title Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **feat**: Introduces a new feature or enhancement to the codebase --- ## Description Open-WebUI currently supports SQLite and PostgreSQL as primary databases. This PR adds **MariaDB** as a supported primary backend database, allowing Open-WebUI to run with MariaDB for application data, migrations, and runtime persistence. My main motivation for proposing this change is operational simplicity: Open-WebUI already supports **MariaDB Vector** as a vector database backend, so adding MariaDB as the primary database allows users to deploy both the main application data and vector storage on a single database system instead of operating multiple database technologies side-by-side. For users who are already committed to MariaDB infrastructure, this means: - fewer moving parts, - simpler deployment and backup strategy, - more consistent operational tooling, - and a lower barrier to adopting Open-WebUI in environments where PostgreSQL is not already standard. This PR is designed as an opt-in compatibility expansion rather than a database-layer redesign. Existing SQLite and PostgreSQL users are unaffected. This work addresses the request to support MariaDB as a main database backend (see discussion #22803). ## Scope of the change This PR adds MariaDB support for the primary backend database by: - enabling MariaDB/MySQL-compatible Peewee connection handling, - normalizing supported SQLAlchemy-style database URLs for Peewee migration/runtime compatibility, - adding reconnect behavior for MySQL/MariaDB in the same style as PostgreSQL, - handling migration edge cases that are not directly compatible with MariaDB/MySQL, - and adding the required MariaDB dependency for runtime and migration flows. This PR is intentionally limited to MariaDB as the primary backend database. ## Design notes This change is intended to stay aligned with the current architecture: - it does **not** introduce a new persistence model, - it does **not** change any default database choice, - it does **not** add UI-level complexity, - it is only activated when users explicitly configure a MariaDB `DATABASE_URL`. The implementation follows the same overall connection/migration pattern already used for existing primary database backends. ## Dependencies New dependency added: - `mariadb` Python driver Rationale: MariaDB primary DB support uses the preferred `mariadb+mariadbconnector://...` URL scheme, which requires the official MariaDB Connector/Python driver. `PyMySQL` remains available as a compatibility fallback for `mysql+pymysql://...`. Compatibility notes: - MariaDB support is opt-in and only affects deployments configured with a MariaDB `DATABASE_URL`. - Existing SQLite and PostgreSQL setups should continue to work unchanged. ## Manual tests Build the Docker image from this branch: ~~~~ {.bash} $ docker build -f Dockerfile -t open-webui:0.9.0-dev . ~~~~ Both test runs below used a fresh empty database before startup. ### MariaDB primary DB + MariaDB vector test #### Start Open-WebUI against MariaDB ~~~~ {.bash} docker run -d \ --network host \ -e OLLAMA_BASE_URL="http://ollama-host.com:11434" \ -e AIOHTTP_CLIENT_TIMEOUT=3600 \ \ -e ENABLE_PERSISTENT_CONFIG=False \ -e DEFAULT_MODEL_PARAMS='{"num_ctx":32768,"temperature":0.1,"top_p":0.9}' \ \ -e RAG_EMBEDDING_ENGINE=ollama \ -e RAG_OLLAMA_BASE_URL="http://ollama-host.com:11434" \ -e RAG_EMBEDDING_MODEL=nomic-embed-text \ -e RAG_EMBEDDING_BATCH_SIZE=64 \ -e RAG_TEXT_SPLITTER=token \ -e RAG_SYSTEM_CONTEXT=True \ -e RAG_TOP_K=10 \ -e RAG_TOP_K_RERANKER=10 \ \ -e CHUNK_SIZE=1024 \ -e CHUNK_OVERLAP=128 \ -e CHUNK_MIN_SIZE_TARGET=640 \ -e ENABLE_ASYNC_EMBEDDING=true \ -e RAG_EMBEDDING_CONCURRENT_REQUESTS=8 \ -e ENABLE_RAG_HYBRID_SEARCH=true \ \ -e DATABASE_URL="mariadb+mariadbconnector://app:app@127.0.0.1:3306/openwebui" \ -e VECTOR_DB="mariadb-vector" \ -e MARIADB_VECTOR_DB_URL="mariadb+mariadbconnector://app:app@127.0.0.1:3306/openwebui" \ -e MARIADB_VECTOR_INITIALIZE_MAX_VECTOR_LENGTH=768 \ -e MARIADB_VECTOR_DISTANCE_STRATEGY=cosine \ -e MARIADB_VECTOR_INDEX_M=12 \ \ -v open-webui:/app/backend/data \ --name open-webui \ --restart always \ open-webui:0.9.0-dev ~~~~ There are no migration/runtime errors: ~~~~ {.bash} server@ai:[debug_open-webui] [] $ docker logs -f open-webui Loading WEBUI_SECRET_KEY from file, not provided as an environment variable. Generating WEBUI_SECRET_KEY Loading WEBUI_SECRET_KEY from .webui_secret_key INFO [alembic.runtime.migration] Context impl MariaDBImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> 7e5b5dc7342b, init INFO [alembic.runtime.migration] Running upgrade 7e5b5dc7342b -> ca81bd47c050, Add config table INFO [alembic.runtime.migration] Running upgrade ca81bd47c050 -> c0fbf31ca0db, Update file table INFO [alembic.runtime.migration] Running upgrade c0fbf31ca0db -> 6a39f3d8e55c, Add knowledge table Creating knowledge table Migrating data from document table to knowledge table INFO [alembic.runtime.migration] Running upgrade 6a39f3d8e55c -> 242a2047eae0, Update chat table Converting 'chat' column to JSON Renaming 'chat' column to 'old_chat' Adding new 'chat' column of type JSON Dropping 'old_chat' column INFO [alembic.runtime.migration] Running upgrade 242a2047eae0 -> 1af9b942657b, Migrate tags INFO [alembic.runtime.migration] Running upgrade 1af9b942657b -> 3ab32c4b8f59, Update tags Primary Key: {'name': None, 'constrained_columns': []} Unique Constraints: [{'name': 'tag_id', 'column_names': ['id'], 'duplicates_index': 'tag_id'}, {'name': 'uq_id_user_id', 'column_names': ['id', 'user_id'], 'duplicates_index': 'uq_id_user_id'}] Indexes: [{'name': 'tag_id', 'column_names': ['id'], 'unique': True, 'type': 'UNIQUE'}, {'name': 'uq_id_user_id', 'column_names': ['id', 'user_id'], 'unique': True, 'type': 'UNIQUE'}] Creating new primary key with 'id' and 'user_id'. Dropping unique constraint: uq_id_user_id INFO [alembic.runtime.migration] Running upgrade 3ab32c4b8f59 -> c69f45358db4, Add folder table INFO [alembic.runtime.migration] Running upgrade c69f45358db4 -> c29facfe716b, Update file table path INFO [alembic.runtime.migration] Running upgrade c29facfe716b -> af906e964978, Add feedback table INFO [alembic.runtime.migration] Running upgrade af906e964978 -> 4ace53fd72c8, Update folder table and change DateTime to BigInteger for timestamp fields INFO [alembic.runtime.migration] Running upgrade 4ace53fd72c8 -> 922e7a387820, Add group table INFO [alembic.runtime.migration] Running upgrade 922e7a387820 -> 57c599a3cb57, Add channel table INFO [alembic.runtime.migration] Running upgrade 57c599a3cb57 -> 7826ab40b532, Update file table INFO [alembic.runtime.migration] Running upgrade 7826ab40b532 -> 3781e22d8b01, Update message & channel tables INFO [alembic.runtime.migration] Running upgrade 3781e22d8b01 -> 9f0c9cd09105, Add note table INFO [alembic.runtime.migration] Running upgrade 9f0c9cd09105 -> d31026856c01, Update folder table data INFO [alembic.runtime.migration] Running upgrade d31026856c01 -> 018012973d35, Add indexes INFO [alembic.runtime.migration] Running upgrade 018012973d35 -> 3af16a1c9fb6, update user table INFO [alembic.runtime.migration] Running upgrade 3af16a1c9fb6 -> 38d63c18f30f, Add oauth_session table INFO [alembic.runtime.migration] Running upgrade 38d63c18f30f -> a5c220713937, Add reply_to_id column to message INFO [alembic.runtime.migration] Running upgrade a5c220713937 -> 37f288994c47, add_group_member_table [] INFO [alembic.runtime.migration] Running upgrade 37f288994c47 -> 2f1211949ecc, Update messages and channel member table INFO [alembic.runtime.migration] Running upgrade 2f1211949ecc -> b10670c03dd5, Update user table INFO [alembic.runtime.migration] Running upgrade b10670c03dd5 -> 90ef40d4714e, Update channel and channel members table INFO [alembic.runtime.migration] Running upgrade 90ef40d4714e -> 3e0e00844bb0, Add knowledge_file table INFO [alembic.runtime.migration] Running upgrade 3e0e00844bb0 -> 6283dc0e4d8d, Add channel file table INFO [alembic.runtime.migration] Running upgrade 6283dc0e4d8d -> 81cc2ce44d79, Update channel file and knowledge table INFO [alembic.runtime.migration] Running upgrade 81cc2ce44d79 -> c440947495f3, Add chat_file table INFO [alembic.runtime.migration] Running upgrade c440947495f3 -> 374d2f66af06, Add prompt history table INFO [alembic.runtime.migration] Running upgrade 374d2f66af06 -> 8452d01d26d7, Add chat_message table INFO [alembic.runtime.migration] Running upgrade 8452d01d26d7 -> f1e2d3c4b5a6, Add access_grant table INFO [alembic.runtime.migration] Running upgrade f1e2d3c4b5a6 -> a1b2c3d4e5f6, Add skill table INFO [alembic.runtime.migration] Running upgrade a1b2c3d4e5f6 -> b2c3d4e5f6a7, add scim column to user table INFO [alembic.runtime.migration] Running upgrade b2c3d4e5f6a7 -> a3dd5bedd151, Add tasks and summary columns to chat table INFO [alembic.runtime.migration] Running upgrade a3dd5bedd151 -> d4e5f6a7b8c9, add automation tables INFO [alembic.runtime.migration] Running upgrade d4e5f6a7b8c9 -> b7c8d9e0f1a2, add last_read_at to chat WARNI [open_webui.env] WARNING: CORS_ALLOW_ORIGIN IS SET TO '*' - NOT RECOMMENDED FOR PRODUCTION DEPLOYMENTS. WARNI [langchain_community.utils.user_agent] USER_AGENT environment variable not set, consider setting it to identify your requests. ██████╗ ██████╗ ███████╗███╗ ██╗ ██╗ ██╗███████╗██████╗ ██╗ ██╗██╗ ██╔═══██╗██╔══██╗██╔════╝████╗ ██║ ██║ ██║██╔════╝██╔══██╗██║ ██║██║ ██║ ██║██████╔╝█████╗ ██╔██╗ ██║ ██║ █╗ ██║█████╗ ██████╔╝██║ ██║██║ ██║ ██║██╔═══╝ ██╔══╝ ██║╚██╗██║ ██║███╗██║██╔══╝ ██╔══██╗██║ ██║██║ ╚██████╔╝██║ ███████╗██║ ╚████║ ╚███╔███╔╝███████╗██████╔╝╚██████╔╝██║ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚══╝╚══╝ ╚══════╝╚═════╝ ╚═════╝ ╚═╝ v0.8.12 - building the best AI user interface. https://github.com/open-webui/open-webui INFO: Started server process [1] INFO: Waiting for application startup. 2026-04-04 17:47:40.165 | INFO | open_webui.utils.logger:start_logger:192 - GLOBAL_LOG_LEVEL: INFO 2026-04-04 17:47:40.166 | INFO | open_webui.main:lifespan:636 - Installing external dependencies of functions and tools... 2026-04-04 17:47:40.187 | INFO | open_webui.utils.plugin:install_frontmatter_requirements:404 - No requirements found in frontmatter. 2026-04-04 17:47:40.187 | INFO | open_webui.utils.automations:automation_worker_loop:106 - Automation worker started (poll interval: 10s) ~~~~ #### Verify migration-created tables exist ~~~~ {.bash} $ mariadb -uapp -papp -D openwebui -e " SELECT version_num FROM alembic_version; SHOW TABLES LIKE 'chat_message'; SHOW TABLES LIKE 'access_grant'; SHOW TABLES LIKE 'automation'; SHOW TABLES LIKE 'automation_run'; " +--------------+ | version_num | +--------------+ | b7c8d9e0f1a2 | +--------------+ +------------------------------------+ | Tables_in_openwebui (chat_message) | +------------------------------------+ | chat_message | +------------------------------------+ +------------------------------------+ | Tables_in_openwebui (access_grant) | +------------------------------------+ | access_grant | +------------------------------------+ +----------------------------------+ | Tables_in_openwebui (automation) | +----------------------------------+ | automation | +----------------------------------+ +--------------------------------------+ | Tables_in_openwebui (automation_run) | +--------------------------------------+ | automation_run | +--------------------------------------+ ~~~~ #### Check important indexes were created ~~~~ {.bash} $ mariadb -uapp -papp -D openwebui -e " SHOW INDEX FROM chat_message; SHOW INDEX FROM access_grant; SHOW INDEX FROM automation_run; " +--------------+------------+--------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Ignored | +--------------+------------+--------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | chat_message | 0 | PRIMARY | 1 | id | A | 2 | NULL | NULL | | BTREE | | | NO | | chat_message | 1 | ix_chat_message_user_id | 1 | user_id | A | 1 | NULL | NULL | YES | BTREE | | | NO | | chat_message | 1 | ix_chat_message_model_id | 1 | model_id | A | 2 | NULL | NULL | YES | BTREE | | | NO | | chat_message | 1 | ix_chat_message_chat_id | 1 | chat_id | A | 1 | NULL | NULL | | BTREE | | | NO | | chat_message | 1 | ix_chat_message_created_at | 1 | created_at | A | 1 | NULL | NULL | YES | BTREE | | | NO | | chat_message | 1 | chat_message_chat_parent_idx | 1 | chat_id | A | 1 | NULL | NULL | | BTREE | | | NO | | chat_message | 1 | chat_message_chat_parent_idx | 2 | parent_id | A | 2 | NULL | NULL | YES | BTREE | | | NO | | chat_message | 1 | chat_message_model_created_idx | 1 | model_id | A | 2 | NULL | NULL | YES | BTREE | | | NO | | chat_message | 1 | chat_message_model_created_idx | 2 | created_at | A | 2 | NULL | NULL | YES | BTREE | | | NO | | chat_message | 1 | chat_message_user_created_idx | 1 | user_id | A | 1 | NULL | NULL | YES | BTREE | | | NO | | chat_message | 1 | chat_message_user_created_idx | 2 | created_at | A | 1 | NULL | NULL | YES | BTREE | | | NO | +--------------+------------+--------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ +--------------+------------+----------------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Ignored | +--------------+------------+----------------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | access_grant | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | | NO | | access_grant | 0 | uq_access_grant_grant | 1 | resource_type | A | 0 | NULL | NULL | | HASH | | | NO | | access_grant | 0 | uq_access_grant_grant | 2 | resource_id | A | 0 | NULL | NULL | | HASH | | | NO | | access_grant | 0 | uq_access_grant_grant | 3 | principal_type | A | 0 | NULL | NULL | | HASH | | | NO | | access_grant | 0 | uq_access_grant_grant | 4 | principal_id | A | 0 | NULL | NULL | | HASH | | | NO | | access_grant | 0 | uq_access_grant_grant | 5 | permission | A | 0 | NULL | NULL | | HASH | | | NO | | access_grant | 1 | idx_access_grant_resource | 1 | resource_type | A | 0 | NULL | NULL | | BTREE | | | NO | | access_grant | 1 | idx_access_grant_resource | 2 | resource_id | A | 0 | NULL | NULL | | BTREE | | | NO | | access_grant | 1 | idx_access_grant_principal | 1 | principal_type | A | 0 | NULL | NULL | | BTREE | | | NO | | access_grant | 1 | idx_access_grant_principal | 2 | principal_id | A | 0 | NULL | NULL | | BTREE | | | NO | +--------------+------------+----------------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ +----------------+------------+---------------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Ignored | +----------------+------------+---------------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | automation_run | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | | NO | | automation_run | 1 | ix_automation_run_automation_id | 1 | automation_id | A | 0 | NULL | NULL | | BTREE | | | NO | +----------------+------------+---------------------------------+--------------+---------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ ~~~~ #### Verify DB rows after manual actions ~~~~ {.bash} $ mariadb -uapp -papp -D openwebui -e " SELECT COUNT(*) AS users_count FROM \`user\`; SELECT COUNT(*) AS file_count FROM file; SELECT COUNT(*) AS knowledge_count FROM knowledge; SELECT COUNT(*) AS knowledge_file_count FROM knowledge_file; " +-------------+ | users_count | +-------------+ | 1 | +-------------+ +------------+ | file_count | +------------+ | 216 | +------------+ +-----------------+ | knowledge_count | +-----------------+ | 1 | +-----------------+ +----------------------+ | knowledge_file_count | +----------------------+ | 216 | +----------------------+ ~~~~ #### Screenshots <img width="1837" height="896" alt="image" src="https://github.com/user-attachments/assets/ccfa39dc-3096-4e7c-976e-b4eb7881a6ee" /> ### PostgesSQL primary DB + pgvector test #### Start Open-WebUI against PostgesSQL ~~~~ {.bash} docker run -d \ --network host \ --name open-webui-pg \ -e PORT=8081 \ --restart always \ -e OLLAMA_BASE_URL="http://ollama-host.com:11434" \ -e AIOHTTP_CLIENT_TIMEOUT=3600 \ \ -e ENABLE_PERSISTENT_CONFIG=False \ -e DEFAULT_MODEL_PARAMS='{"num_ctx":32768,"temperature":0.1,"top_p":0.9}' \ \ -e RAG_EMBEDDING_ENGINE=ollama \ -e RAG_OLLAMA_BASE_URL="http://ollama-host.com:11434" \ -e RAG_EMBEDDING_MODEL=nomic-embed-text \ -e RAG_EMBEDDING_BATCH_SIZE=64 \ -e RAG_TEXT_SPLITTER=token \ -e RAG_SYSTEM_CONTEXT=True \ -e RAG_TOP_K=10 \ -e RAG_TOP_K_RERANKER=10 \ \ -e CHUNK_SIZE=1024 \ -e CHUNK_OVERLAP=128 \ -e CHUNK_MIN_SIZE_TARGET=640 \ -e ENABLE_ASYNC_EMBEDDING=true \ -e RAG_EMBEDDING_CONCURRENT_REQUESTS=8 \ -e ENABLE_RAG_HYBRID_SEARCH=true \ \ -e DATABASE_URL="postgres://app_pg:app_pg@127.0.0.1:5432/openwebui_pg" \ -e VECTOR_DB="pgvector" \ -e PGVECTOR_DB_URL="postgresql+psycopg2://app_pg:app_pg@127.0.0.1:5432/openwebui_pg" \ -e PGVECTOR_INITIALIZE_MAX_VECTOR_LENGTH=768 \ -e PGVECTOR_CREATE_EXTENSION=true \ -e PGVECTOR_PGCRYPTO=false \ -v open-webui-pg:/app/backend/data \ open-webui:0.9.0-dev ~~~~ There are no migration/runtime errors: ~~~~ {.bash} server@ai:[debug_open-webui] [] $ docker logs -f open-webui-pg Loading WEBUI_SECRET_KEY from file, not provided as an environment variable. Generating WEBUI_SECRET_KEY Loading WEBUI_SECRET_KEY from .webui_secret_key INFO [alembic.runtime.migration] Context impl PostgresqlImpl. INFO [alembic.runtime.migration] Will assume transactional DDL. INFO [alembic.runtime.migration] Running upgrade -> 7e5b5dc7342b, init INFO [alembic.runtime.migration] Running upgrade 7e5b5dc7342b -> ca81bd47c050, Add config table INFO [alembic.runtime.migration] Running upgrade ca81bd47c050 -> c0fbf31ca0db, Update file table Creating knowledge table INFO [alembic.runtime.migration] Running upgrade c0fbf31ca0db -> 6a39f3d8e55c, Add knowledge table Migrating data from document table to knowledge table INFO [alembic.runtime.migration] Running upgrade 6a39f3d8e55c -> 242a2047eae0, Update chat table Converting 'chat' column to JSON Renaming 'chat' column to 'old_chat' Adding new 'chat' column of type JSON Dropping 'old_chat' column INFO [alembic.runtime.migration] Running upgrade 242a2047eae0 -> 1af9b942657b, Migrate tags INFO [alembic.runtime.migration] Running upgrade 1af9b942657b -> 3ab32c4b8f59, Update tags Primary Key: {'name': None, 'constrained_columns': []} Unique Constraints: [{'column_names': ['id', 'user_id'], 'name': 'uq_id_user_id', 'comment': None, 'dialect_options': {'postgresql_include': [], 'postgresql_nulls_not_distinct': False}}] Indexes: [{'name': 'tag_id', 'unique': True, 'column_names': ['id'], 'include_columns': [], 'dialect_options': {'postgresql_include': []}}, {'name': 'uq_id_user_id', 'unique': True, 'column_names': ['id', 'user_id'], 'duplicates_constraint': 'uq_id_user_id', 'include_columns': [], 'dialect_options': {'postgresql_include': []}}] Creating new primary key with 'id' and 'user_id'. Dropping unique constraint: uq_id_user_id Dropping unique index: tag_id INFO [alembic.runtime.migration] Running upgrade 3ab32c4b8f59 -> c69f45358db4, Add folder table INFO [alembic.runtime.migration] Running upgrade c69f45358db4 -> c29facfe716b, Update file table path INFO [alembic.runtime.migration] Running upgrade c29facfe716b -> af906e964978, Add feedback table INFO [alembic.runtime.migration] Running upgrade af906e964978 -> 4ace53fd72c8, Update folder table and change DateTime to BigInteger for timestamp fields INFO [alembic.runtime.migration] Running upgrade 4ace53fd72c8 -> 922e7a387820, Add group table INFO [alembic.runtime.migration] Running upgrade 922e7a387820 -> 57c599a3cb57, Add channel table INFO [alembic.runtime.migration] Running upgrade 57c599a3cb57 -> 7826ab40b532, Update file table INFO [alembic.runtime.migration] Running upgrade 7826ab40b532 -> 3781e22d8b01, Update message & channel tables INFO [alembic.runtime.migration] Running upgrade 3781e22d8b01 -> 9f0c9cd09105, Add note table INFO [alembic.runtime.migration] Running upgrade 9f0c9cd09105 -> d31026856c01, Update folder table data INFO [alembic.runtime.migration] Running upgrade d31026856c01 -> 018012973d35, Add indexes INFO [alembic.runtime.migration] Running upgrade 018012973d35 -> 3af16a1c9fb6, update user table INFO [alembic.runtime.migration] Running upgrade 3af16a1c9fb6 -> 38d63c18f30f, Add oauth_session table INFO [alembic.runtime.migration] Running upgrade 38d63c18f30f -> a5c220713937, Add reply_to_id column to message INFO [alembic.runtime.migration] Running upgrade a5c220713937 -> 37f288994c47, add_group_member_table [] INFO [alembic.runtime.migration] Running upgrade 37f288994c47 -> 2f1211949ecc, Update messages and channel member table INFO [alembic.runtime.migration] Running upgrade 2f1211949ecc -> b10670c03dd5, Update user table INFO [alembic.runtime.migration] Running upgrade b10670c03dd5 -> 90ef40d4714e, Update channel and channel members table INFO [alembic.runtime.migration] Running upgrade 90ef40d4714e -> 3e0e00844bb0, Add knowledge_file table INFO [alembic.runtime.migration] Running upgrade 3e0e00844bb0 -> 6283dc0e4d8d, Add channel file table INFO [alembic.runtime.migration] Running upgrade 6283dc0e4d8d -> 81cc2ce44d79, Update channel file and knowledge table INFO [alembic.runtime.migration] Running upgrade 81cc2ce44d79 -> c440947495f3, Add chat_file table INFO [alembic.runtime.migration] Running upgrade c440947495f3 -> 374d2f66af06, Add prompt history table INFO [alembic.runtime.migration] Running upgrade 374d2f66af06 -> 8452d01d26d7, Add chat_message table INFO [alembic.runtime.migration] Running upgrade 8452d01d26d7 -> f1e2d3c4b5a6, Add access_grant table INFO [alembic.runtime.migration] Running upgrade f1e2d3c4b5a6 -> a1b2c3d4e5f6, Add skill table INFO [alembic.runtime.migration] Running upgrade a1b2c3d4e5f6 -> b2c3d4e5f6a7, add scim column to user table INFO [alembic.runtime.migration] Running upgrade b2c3d4e5f6a7 -> a3dd5bedd151, Add tasks and summary columns to chat table INFO [alembic.runtime.migration] Running upgrade a3dd5bedd151 -> d4e5f6a7b8c9, add automation tables INFO [alembic.runtime.migration] Running upgrade d4e5f6a7b8c9 -> b7c8d9e0f1a2, add last_read_at to chat WARNI [open_webui.env] WARNING: CORS_ALLOW_ORIGIN IS SET TO '*' - NOT RECOMMENDED FOR PRODUCTION DEPLOYMENTS. WARNI [langchain_community.utils.user_agent] USER_AGENT environment variable not set, consider setting it to identify your requests. ██████╗ ██████╗ ███████╗███╗ ██╗ ██╗ ██╗███████╗██████╗ ██╗ ██╗██╗ ██╔═══██╗██╔══██╗██╔════╝████╗ ██║ ██║ ██║██╔════╝██╔══██╗██║ ██║██║ ██║ ██║██████╔╝█████╗ ██╔██╗ ██║ ██║ █╗ ██║█████╗ ██████╔╝██║ ██║██║ ██║ ██║██╔═══╝ ██╔══╝ ██║╚██╗██║ ██║███╗██║██╔══╝ ██╔══██╗██║ ██║██║ ╚██████╔╝██║ ███████╗██║ ╚████║ ╚███╔███╔╝███████╗██████╔╝╚██████╔╝██║ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚══╝╚══╝ ╚══════╝╚═════╝ ╚═════╝ ╚═╝ v0.8.12 - building the best AI user interface. https://github.com/open-webui/open-webui INFO: Started server process [1] INFO: Waiting for application startup. 2026-04-04 17:55:43.851 | INFO | open_webui.utils.logger:start_logger:192 - GLOBAL_LOG_LEVEL: INFO 2026-04-04 17:55:43.851 | INFO | open_webui.main:lifespan:636 - Installing external dependencies of functions and tools... 2026-04-04 17:55:43.873 | INFO | open_webui.utils.plugin:install_frontmatter_requirements:404 - No requirements found in frontmatter. 2026-04-04 17:55:43.873 | INFO | open_webui.utils.automations:automation_worker_loop:106 - Automation worker started (poll interval: 10s) ~~~~ #### Verify migration-created tables exist ~~~~ {.bash} $ PGPASSWORD=app_pg psql -h 127.0.0.1 -U app_pg -d openwebui_pg -c " SELECT version_num FROM alembic_version; SELECT tablename FROM pg_tables WHERE tablename IN ('chat_message','access_grant','automation','automation_run'); " version_num -------------- b7c8d9e0f1a2 (1 row) tablename ---------------- automation automation_run chat_message access_grant (4 rows) ~~~~ #### Verify DB rows after manual actions ~~~~ {.bash} $ PGPASSWORD=app_pg psql -h 127.0.0.1 -U app_pg -d openwebui_pg -c ' SELECT COUNT(*) AS users_count FROM "user"; SELECT COUNT(*) AS file_count FROM file; SELECT COUNT(*) AS knowledge_count FROM knowledge; SELECT COUNT(*) AS knowledge_file_count FROM knowledge_file; ' users_count ------------- 1 (1 row) file_count ------------ 216 (1 row) knowledge_count ----------------- 1 (1 row) knowledge_file_count ---------------------- 216 (1 row) ~~~~ #### Screenshots <img width="1837" height="896" alt="image" src="https://github.com/user-attachments/assets/bd685446-0e60-40d6-9aaa-92aec0c38d47" /> ## Observed outcome - Fresh bootstrap succeeded on MariaDB - Fresh bootstrap succeeded on PostgreSQL - alembic_version reached head on both - chat_message, access_grant, automation, automation_run tables created successfully - Admin signup/login worked - Knowledge file upload worked - Persisted rows verified in DB ## Documentation - I have already added documentation to https://github.com/open-webui/docs : https://github.com/open-webui/docs/pull/1165 --- ## Changelog Entry ### Description - Add MariaDB as a supported primary database backend so Open-WebUI can run its main application data on MariaDB, including deployments that also use MariaDB Vector for embeddings. ### Added - Added MariaDB support for the primary backend database. ### Changed - Updated database connection and migration compatibility logic to support MariaDB-backed deployments. --- ### Additional Information - Open-WebUI already supports `mariadb-vector` on the vector database side; this PR complements that by enabling MariaDB for the primary database as well. - The primary value of this change is **single-database-system deployment** for users standardized on MariaDB. - This PR is intentionally scoped to one logical change: MariaDB as a primary backend database. --- ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <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 2026-04-30 02:51:29 -05: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#50230