diff --git a/app/__init__.py b/app/__init__.py index 1f27be3..832205a 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -124,6 +124,13 @@ def create_app(): if "is_typical" not in plan_columns2: db.session.execute(text("ALTER TABLE practice_plans ADD COLUMN is_typical INTEGER DEFAULT 0")) db.session.commit() + + # 检查goals表是否有level字段 + result7 = db.session.execute(text("PRAGMA table_info(goals)")) + goal_columns = [row[1] for row in result7] + if "level" not in goal_columns: + db.session.execute(text("ALTER TABLE goals ADD COLUMN level VARCHAR(20) DEFAULT '入门'")) + db.session.commit() except Exception as e: print(f"数据库迁移: {e}")