Refactoring

This commit is contained in:
Carsten Graf
2026-01-23 14:13:18 +01:00
parent 33c62a7a2a
commit a0acd188a8
22 changed files with 2392 additions and 1611 deletions

View File

@@ -2,7 +2,8 @@ const sqlite3 = require('sqlite3').verbose();
const bcrypt = require('bcryptjs');
const path = require('path');
const dbPath = path.join(__dirname, 'stundenerfassung.db');
// Datenbank-Pfad: Umgebungsvariable oder Standard-Pfad
const dbPath = process.env.DB_PATH || path.join(__dirname, 'stundenerfassung.db');
const db = new sqlite3.Database(dbPath);
// Datenbank initialisieren
@@ -183,6 +184,27 @@ function initDatabase() {
db.run(`ALTER TABLE users ADD COLUMN urlaubstage REAL`, (err) => {
// Fehler ignorieren wenn Spalte bereits existiert
});
// Migration: ping_ip Spalte hinzufügen
db.run(`ALTER TABLE users ADD COLUMN ping_ip TEXT`, (err) => {
// Fehler ignorieren wenn Spalte bereits existiert
});
// Ping-Status-Tabelle für IP-basierte Zeiterfassung
db.run(`CREATE TABLE IF NOT EXISTS ping_status (
user_id INTEGER NOT NULL,
date TEXT NOT NULL,
last_successful_ping DATETIME,
failed_ping_count INTEGER DEFAULT 0,
start_time_set INTEGER DEFAULT 0,
first_failed_ping_time DATETIME,
PRIMARY KEY (user_id, date),
FOREIGN KEY (user_id) REFERENCES users(id)
)`, (err) => {
if (err && !err.message.includes('duplicate column')) {
console.warn('Warnung beim Erstellen der ping_status Tabelle:', err.message);
}
});
// LDAP-Konfiguration-Tabelle
db.run(`CREATE TABLE IF NOT EXISTS ldap_config (