fix: sys_config seed 补充 app_name 字段

- seed.sql 添加 app_name 默认值
- init.ts 迁移中添加 app_name 兼容已有数据库
This commit is contained in:
2026-06-08 11:13:27 +08:00
parent 8b5589192d
commit ecfb67872d
2 changed files with 10 additions and 0 deletions

View File

@@ -187,12 +187,21 @@ async function runMigrations(conn: mysql.Connection) {
// 插入默认配置
await conn.query(`
INSERT IGNORE INTO sys_config (config_key, config_value) VALUES
('app_name', '小菜记账'),
('app_version', '1.0.0'),
('app_slogan', '温暖 x 轻松的个人记账小程序'),
('app_description', '让记账从负担变成享受')
`)
}
// 确保 app_name 配置存在(兼容已有数据库)
const [appNameRows] = await conn.query(
"SELECT COUNT(*) as cnt FROM sys_config WHERE config_key = 'app_name'"
)
if ((appNameRows as any[])[0].cnt === 0) {
await conn.query("INSERT INTO sys_config (config_key, config_value) VALUES ('app_name', '小菜记账')")
}
// 反馈表
const hasFeedbacks = await tableExists(conn, 'feedbacks')
if (!hasFeedbacks) {

View File

@@ -18,6 +18,7 @@ INSERT IGNORE INTO categories (user_id, name, icon, color, type, sort_order) VAL
-- 系统配置
INSERT IGNORE INTO sys_config (config_key, config_value) VALUES
('app_name', '小菜记账'),
('app_version', '1.0.0'),
('app_slogan', '温暖 x 轻松的个人记账小程序'),
('app_description', '让记账从负担变成享受');