From ecfb67872db64f54bf06bb6ce19b651cdf7bf0d2 Mon Sep 17 00:00:00 2001 From: wangxiaogang <1433729587@qq.com> Date: Mon, 8 Jun 2026 11:13:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20sys=5Fconfig=20seed=20=E8=A1=A5=E5=85=85?= =?UTF-8?q?=20app=5Fname=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - seed.sql 添加 app_name 默认值 - init.ts 迁移中添加 app_name 兼容已有数据库 --- server/src/db/init.ts | 9 +++++++++ server/src/db/seed.sql | 1 + 2 files changed, 10 insertions(+) diff --git a/server/src/db/init.ts b/server/src/db/init.ts index c7f00ee..f761298 100644 --- a/server/src/db/init.ts +++ b/server/src/db/init.ts @@ -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) { diff --git a/server/src/db/seed.sql b/server/src/db/seed.sql index 9071259..10ac8ef 100644 --- a/server/src/db/seed.sql +++ b/server/src/db/seed.sql @@ -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', '让记账从负担变成享受');