()
| 50 | } |
| 51 | |
| 52 | setupDatabase() { |
| 53 | debugLog('📂 Setting up database connection...'); |
| 54 | // 更健壮的数据库路径 |
| 55 | const __filename = fileURLToPath(import.meta.url); |
| 56 | const __dirname = path.dirname(__filename); |
| 57 | const dbPath = path.join(__dirname, 'data', 'icss.db'); |
| 58 | debugLog(`📍 Database path: ${dbPath}`); |
| 59 | this.db = new Database.Database(dbPath, (err) => { |
| 60 | if (err) { |
| 61 | console.error('❌ Error opening database:', err); |
| 62 | this.dbInitFailed = true; |
| 63 | } else { |
| 64 | debugLog('✅ Connected to SQLite database'); |
| 65 | this.initializeDatabase(); |
| 66 | } |
| 67 | }); |
| 68 | } |
| 69 | |
| 70 | initializeDatabase() { |
| 71 | debugLog('🔧 Initializing database tables...'); |
no test coverage detected