mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-27 11:45:20 +00:00
enh: ENABLE_DB_MIGRATIONS
This commit is contained in:
parent
117b1bfa65
commit
9824f0e333
3 changed files with 8 additions and 2 deletions
|
|
@ -19,6 +19,7 @@ from authlib.integrations.starlette_client import OAuth
|
||||||
from open_webui.env import (
|
from open_webui.env import (
|
||||||
DATA_DIR,
|
DATA_DIR,
|
||||||
DATABASE_URL,
|
DATABASE_URL,
|
||||||
|
ENABLE_DB_MIGRATIONS,
|
||||||
ENV,
|
ENV,
|
||||||
REDIS_URL,
|
REDIS_URL,
|
||||||
REDIS_KEY_PREFIX,
|
REDIS_KEY_PREFIX,
|
||||||
|
|
@ -67,7 +68,8 @@ def run_migrations():
|
||||||
log.exception(f"Error running migrations: {e}")
|
log.exception(f"Error running migrations: {e}")
|
||||||
|
|
||||||
|
|
||||||
run_migrations()
|
if ENABLE_DB_MIGRATIONS:
|
||||||
|
run_migrations()
|
||||||
|
|
||||||
|
|
||||||
class Config(Base):
|
class Config(Base):
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,8 @@ VERSION = PACKAGE_DATA["version"]
|
||||||
DEPLOYMENT_ID = os.environ.get("DEPLOYMENT_ID", "")
|
DEPLOYMENT_ID = os.environ.get("DEPLOYMENT_ID", "")
|
||||||
INSTANCE_ID = os.environ.get("INSTANCE_ID", str(uuid4()))
|
INSTANCE_ID = os.environ.get("INSTANCE_ID", str(uuid4()))
|
||||||
|
|
||||||
|
ENABLE_DB_MIGRATIONS = os.environ.get("ENABLE_DB_MIGRATIONS", "True").lower() == "true"
|
||||||
|
|
||||||
|
|
||||||
# Function to parse each section
|
# Function to parse each section
|
||||||
def parse_section(section):
|
def parse_section(section):
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ from open_webui.env import (
|
||||||
DATABASE_POOL_SIZE,
|
DATABASE_POOL_SIZE,
|
||||||
DATABASE_POOL_TIMEOUT,
|
DATABASE_POOL_TIMEOUT,
|
||||||
DATABASE_ENABLE_SQLITE_WAL,
|
DATABASE_ENABLE_SQLITE_WAL,
|
||||||
|
ENABLE_DB_MIGRATIONS,
|
||||||
)
|
)
|
||||||
from peewee_migrate import Router
|
from peewee_migrate import Router
|
||||||
from sqlalchemy import Dialect, create_engine, MetaData, event, types
|
from sqlalchemy import Dialect, create_engine, MetaData, event, types
|
||||||
|
|
@ -75,7 +76,8 @@ def handle_peewee_migration(DATABASE_URL):
|
||||||
assert db.is_closed(), "Database connection is still open."
|
assert db.is_closed(), "Database connection is still open."
|
||||||
|
|
||||||
|
|
||||||
handle_peewee_migration(DATABASE_URL)
|
if ENABLE_DB_MIGRATIONS:
|
||||||
|
handle_peewee_migration(DATABASE_URL)
|
||||||
|
|
||||||
|
|
||||||
SQLALCHEMY_DATABASE_URL = DATABASE_URL
|
SQLALCHEMY_DATABASE_URL = DATABASE_URL
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue