Overtime Corrections mit Historie und Grund
This commit is contained in:
25
database.js
25
database.js
@@ -215,6 +215,31 @@ function initDatabase() {
|
||||
}
|
||||
});
|
||||
|
||||
// Tabelle: Protokoll für Überstunden-Korrekturen durch Verwaltung
|
||||
db.run(`CREATE TABLE IF NOT EXISTS overtime_corrections (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
correction_hours REAL NOT NULL,
|
||||
reason TEXT,
|
||||
corrected_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||
)`, (err) => {
|
||||
if (err) {
|
||||
console.warn('Warnung beim Erstellen der overtime_corrections Tabelle:', err.message);
|
||||
}
|
||||
});
|
||||
|
||||
// Migration: reason Spalte für overtime_corrections hinzufügen (falls Tabelle bereits existiert)
|
||||
db.run(`ALTER TABLE overtime_corrections ADD COLUMN reason TEXT`, (err) => {
|
||||
// Fehler ignorieren wenn Spalte bereits existiert
|
||||
if (err && !err.message.includes('duplicate column')) {
|
||||
// "duplicate column" ist SQLite CLI wording; sqlite3 node liefert typischerweise "duplicate column name"
|
||||
if (!err.message.includes('duplicate column name')) {
|
||||
console.warn('Warnung beim Hinzufügen der Spalte reason (overtime_corrections):', err.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Migration: Urlaubstage-Offset (manuelle Korrektur durch Verwaltung)
|
||||
db.run(`ALTER TABLE users ADD COLUMN vacation_offset_days REAL DEFAULT 0`, (err) => {
|
||||
// Fehler ignorieren wenn Spalte bereits existiert
|
||||
|
||||
Reference in New Issue
Block a user