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:
@@ -2,6 +2,7 @@ from contextlib import asynccontextmanager
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from app.database import init_db
|
from app.database import init_db
|
||||||
|
import app.models # noqa: F401 - 注册所有模型
|
||||||
from app.routers import (
|
from app.routers import (
|
||||||
auth_router,
|
auth_router,
|
||||||
conversation_router,
|
conversation_router,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from app.models.conversation import Conversation, Message
|
|||||||
from app.models.knowledge_graph import KGNode, KGEdge
|
from app.models.knowledge_graph import KGNode, KGEdge
|
||||||
from app.models.memory import MemorySummary, UserMemory
|
from app.models.memory import MemorySummary, UserMemory
|
||||||
from app.models.todo import DailyTodo, TodoSource
|
from app.models.todo import DailyTodo, TodoSource
|
||||||
|
from app.models.log import Log, LogType, LogLevel
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Base",
|
"Base",
|
||||||
@@ -28,4 +29,7 @@ __all__ = [
|
|||||||
"UserMemory",
|
"UserMemory",
|
||||||
"DailyTodo",
|
"DailyTodo",
|
||||||
"TodoSource",
|
"TodoSource",
|
||||||
|
"Log",
|
||||||
|
"LogType",
|
||||||
|
"LogLevel",
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user