fix: 添加goals表level字段的数据库迁移
This commit is contained in:
@@ -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}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user