From 54a1bf141b93caeecbb30565433b0e7a49db0e88 Mon Sep 17 00:00:00 2001 From: imeepos Date: Fri, 26 Sep 2025 15:29:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=BF=9E=E6=8E=A5=E9=85=8D=E7=BD=AE=E5=92=8C=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 禁用云函数环境下的自动迁移 - 增加连接超时和重试机制配置 - 优化连接池参数设置 - 提升数据库连接稳定性和性能 --- src/config/database.config.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/config/database.config.ts b/src/config/database.config.ts index 0cdf2c5..bc170e1 100644 --- a/src/config/database.config.ts +++ b/src/config/database.config.ts @@ -20,7 +20,19 @@ export const databaseConfig = ( 'DB_LOGGING', process.env.NODE_ENV === 'development', ), - migrationsRun: configService.get('DB_MIGRATIONS_RUN', true), // 自动运行迁移 + migrationsRun: configService.get('DB_MIGRATIONS_RUN', false), // 云函数环境禁用自动迁移 charset: 'utf8mb4', timezone: '+08:00', + // 添加连接超时和重试配置 + connectTimeout: 60000, // 60秒连接超时 + acquireTimeout: 60000, // 60秒获取连接超时 + retryAttempts: 3, // 重试3次 + retryDelay: 3000, // 重试间隔3秒 + // 连接池配置 + extra: { + connectionLimit: 10, + idleTimeout: 30000, + acquireTimeout: 60000, + timeout: 60000, // 60秒查询超时 + }, });