fix: 脚本独立运行时缺少init_db(),导致Topic表org_id列不存在,创作按钮点击后生成文章失败
This commit is contained in:
@@ -13,10 +13,13 @@ PROJECT_ROOT = Path(__file__).parent.parent
|
|||||||
sys.path.insert(0, str(PROJECT_ROOT))
|
sys.path.insert(0, str(PROJECT_ROOT))
|
||||||
sys.path.insert(0, str(PROJECT_ROOT / 'platform' / 'backend'))
|
sys.path.insert(0, str(PROJECT_ROOT / 'platform' / 'backend'))
|
||||||
|
|
||||||
from app.database import SessionLocal
|
from app.database import SessionLocal, init_db
|
||||||
from app.models import Topic
|
from app.models import Topic
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
|
# 确保数据库 schema 最新(含 org_id 等迁移)
|
||||||
|
init_db()
|
||||||
|
|
||||||
def get_topic_by_id(topic_id: str, db: Optional[Session] = None) -> Optional[Dict]:
|
def get_topic_by_id(topic_id: str, db: Optional[Session] = None) -> Optional[Dict]:
|
||||||
close_db = False
|
close_db = False
|
||||||
if db is None:
|
if db is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user