enh: ENABLE_DB_MIGRATIONS
This commit is contained in:
@@ -19,6 +19,7 @@ from authlib.integrations.starlette_client import OAuth
|
||||
from open_webui.env import (
|
||||
DATA_DIR,
|
||||
DATABASE_URL,
|
||||
ENABLE_DB_MIGRATIONS,
|
||||
ENV,
|
||||
REDIS_URL,
|
||||
REDIS_KEY_PREFIX,
|
||||
@@ -67,7 +68,8 @@ def run_migrations():
|
||||
log.exception(f"Error running migrations: {e}")
|
||||
|
||||
|
||||
run_migrations()
|
||||
if ENABLE_DB_MIGRATIONS:
|
||||
run_migrations()
|
||||
|
||||
|
||||
class Config(Base):
|
||||
|
||||
@@ -117,6 +117,8 @@ VERSION = PACKAGE_DATA["version"]
|
||||
DEPLOYMENT_ID = os.environ.get("DEPLOYMENT_ID", "")
|
||||
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
|
||||
def parse_section(section):
|
||||
|
||||
@@ -14,6 +14,7 @@ from open_webui.env import (
|
||||
DATABASE_POOL_SIZE,
|
||||
DATABASE_POOL_TIMEOUT,
|
||||
DATABASE_ENABLE_SQLITE_WAL,
|
||||
ENABLE_DB_MIGRATIONS,
|
||||
)
|
||||
from peewee_migrate import Router
|
||||
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."
|
||||
|
||||
|
||||
handle_peewee_migration(DATABASE_URL)
|
||||
if ENABLE_DB_MIGRATIONS:
|
||||
handle_peewee_migration(DATABASE_URL)
|
||||
|
||||
|
||||
SQLALCHEMY_DATABASE_URL = DATABASE_URL
|
||||
|
||||
Reference in New Issue
Block a user