From 5f1dcc08fb4f72157099071e17746d0faae7641c Mon Sep 17 00:00:00 2001 From: hmo Date: Thu, 23 Apr 2026 21:13:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0goals=E8=A1=A8level?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93=E8=BF=81?= =?UTF-8?q?=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) 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}")