fix: 添加数据库初始化检查逻辑,确保操作日志表存在
This commit is contained in:
parent
28321962f5
commit
a6163bfc1c
@ -35,6 +35,15 @@ oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
|||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
# 初始化数据库表(使用IF NOT EXISTS语法,不会覆盖已有表)
|
||||||
|
try:
|
||||||
|
from database import init_sqlite_db
|
||||||
|
init_sqlite_db()
|
||||||
|
logger.info("数据库表检查完成,缺失的表已创建")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"数据库表初始化失败: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
# 添加CORS中间件
|
# 添加CORS中间件
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user