Remove runtime scheme compatibility
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from sqlalchemy import create_engine, text
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker, DeclarativeBase
|
||||
import os
|
||||
|
||||
@@ -14,32 +14,6 @@ class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
|
||||
def ensure_schema_compatibility() -> None:
|
||||
"""Best-effort lightweight migrations for SQLite deployments."""
|
||||
if engine.dialect.name != "sqlite":
|
||||
return
|
||||
|
||||
with engine.begin() as conn:
|
||||
columns = {
|
||||
row[1]
|
||||
for row in conn.execute(text("PRAGMA table_info(assistants)"))
|
||||
}
|
||||
if "voice_output_enabled" not in columns:
|
||||
conn.execute(
|
||||
text(
|
||||
"ALTER TABLE assistants "
|
||||
"ADD COLUMN voice_output_enabled BOOLEAN DEFAULT 1"
|
||||
)
|
||||
)
|
||||
conn.execute(
|
||||
text(
|
||||
"UPDATE assistants "
|
||||
"SET voice_output_enabled = 1 "
|
||||
"WHERE voice_output_enabled IS NULL"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def get_db():
|
||||
db = SessionLocal()
|
||||
try:
|
||||
|
||||
@@ -3,7 +3,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
from contextlib import asynccontextmanager
|
||||
import os
|
||||
|
||||
from .db import Base, engine, ensure_schema_compatibility
|
||||
from .db import Base, engine
|
||||
from .routers import assistants, voices, workflows, history, knowledge, llm, asr, tools
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ from .routers import assistants, voices, workflows, history, knowledge, llm, asr
|
||||
async def lifespan(app: FastAPI):
|
||||
# 启动时创建表
|
||||
Base.metadata.create_all(bind=engine)
|
||||
ensure_schema_compatibility()
|
||||
yield
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user