mirror of
https://github.com/patdelphi/suanming.git
synced 2026-03-06 16:43:12 +08:00
feat: 完善Koyeb数据库持久化配置
- 更新.koyeb/koyeb.yaml添加完整环境变量配置 - 添加DB_PATH明确指定生产环境数据库路径 - 增强数据库管理器日志输出,显示路径和环境信息 - 添加数据库目录创建状态日志 - 更新.env.example添加数据库配置说明 - 确保本地开发和Koyeb生产环境数据库路径正确分离 - 实现完整的数据库持久化方案
This commit is contained in:
@@ -10,6 +10,11 @@ class DatabaseManager {
|
||||
? '/app/data/numerology.db'
|
||||
: path.join(__dirname, '../../numerology.db');
|
||||
this.schemaPath = path.join(__dirname, 'schema.sql');
|
||||
|
||||
// 输出数据库配置信息
|
||||
console.log(`🗄️ 数据库路径: ${this.dbPath}`);
|
||||
console.log(`🌍 运行环境: ${process.env.NODE_ENV || 'development'}`);
|
||||
console.log(`📊 数据库文件: ${path.basename(this.dbPath)}`);
|
||||
}
|
||||
|
||||
// 初始化数据库连接
|
||||
@@ -19,6 +24,9 @@ class DatabaseManager {
|
||||
const dbDir = path.dirname(this.dbPath);
|
||||
if (!fs.existsSync(dbDir)) {
|
||||
fs.mkdirSync(dbDir, { recursive: true });
|
||||
console.log(`📁 创建数据库目录: ${dbDir}`);
|
||||
} else {
|
||||
console.log(`📁 数据库目录已存在: ${dbDir}`);
|
||||
}
|
||||
|
||||
// 创建或连接到SQLite数据库
|
||||
|
||||
Reference in New Issue
Block a user