fix: init_db兼容旧数据库,自动添加缺失的系统配置字段
This commit is contained in:
@@ -276,6 +276,20 @@ def init_db():
|
|||||||
]
|
]
|
||||||
for key, value, desc in default_configs:
|
for key, value, desc in default_configs:
|
||||||
cursor.execute('INSERT INTO system_configs (key, value, description) VALUES (?, ?, ?)', (key, value, desc))
|
cursor.execute('INSERT INTO system_configs (key, value, description) VALUES (?, ?, ?)', (key, value, desc))
|
||||||
|
else:
|
||||||
|
# 检查并添加缺失的配置项(兼容旧数据库)
|
||||||
|
default_configs = [
|
||||||
|
('app_developer', 'OpenClaw Team', '开发者'),
|
||||||
|
('app_update_date', '2026-04-27', '更新日期'),
|
||||||
|
('app_technology', '智谱 GLM-4.5-Air 大模型', '技术基础'),
|
||||||
|
('app_description', '提供智能对话、多种智能体服务', '应用简介'),
|
||||||
|
('privacy_policy_url', '', '隐私政策链接'),
|
||||||
|
('user_agreement_url', '', '用户协议链接'),
|
||||||
|
]
|
||||||
|
for key, value, desc in default_configs:
|
||||||
|
cursor.execute('SELECT COUNT(*) FROM system_configs WHERE key=?', (key,))
|
||||||
|
if cursor.fetchone()[0] == 0:
|
||||||
|
cursor.execute('INSERT INTO system_configs (key, value, description) VALUES (?, ?, ?)', (key, value, desc))
|
||||||
|
|
||||||
# 初始化管理员账户
|
# 初始化管理员账户
|
||||||
cursor.execute('SELECT COUNT(*) FROM admin_users')
|
cursor.execute('SELECT COUNT(*) FROM admin_users')
|
||||||
|
|||||||
Reference in New Issue
Block a user