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秒查询超时 + }, });