Fix Log model registration - import models before init_db

The Log model was not being registered with SQLAlchemy's metadata,
causing the logs table to not be created on startup.
This commit is contained in:
2026-03-21 12:02:35 +08:00
parent ca69a35e02
commit 204cb223a3
2 changed files with 5 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.database import init_db
import app.models # noqa: F401 - 注册所有模型
from app.routers import (
auth_router,
conversation_router,

View File

@@ -8,6 +8,7 @@ from app.models.conversation import Conversation, Message
from app.models.knowledge_graph import KGNode, KGEdge
from app.models.memory import MemorySummary, UserMemory
from app.models.todo import DailyTodo, TodoSource
from app.models.log import Log, LogType, LogLevel
__all__ = [
"Base",
@@ -28,4 +29,7 @@ __all__ = [
"UserMemory",
"DailyTodo",
"TodoSource",
"Log",
"LogType",
"LogLevel",
]