-- Abwesenheiten der Mitarbeiter (Urlaub, Krankheit, Sonstiges). -- -- Eine Zeile beschreibt einen zusammenhängenden Zeitraum (start_date … -- end_date, jeweils inklusive). Die Liste ist für alle sichtbar; pflegen darf -- jeder Mitarbeiter seine eigenen Einträge, Admins alle. -- -- Buchungen werden abgelehnt, wenn der zuständige Mitarbeiter im Zeitraum der -- Buchung inklusive Vorlauf (Erinnerung 8 Tage vor Mietbeginn) abwesend ist. CREATE TABLE IF NOT EXISTS absences ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, employee_id BIGINT UNSIGNED NOT NULL, start_date DATE NOT NULL, end_date DATE NOT NULL, note VARCHAR(160) NOT NULL DEFAULT '', created_by BIGINT UNSIGNED NULL DEFAULT NULL, updated_by BIGINT UNSIGNED NULL DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY (id), KEY idx_absences_employee (employee_id, start_date, end_date), KEY idx_absences_period (start_date, end_date), CONSTRAINT fk_absences_employee FOREIGN KEY (employee_id) REFERENCES employees (id) ON DELETE CASCADE, CONSTRAINT fk_absences_created_by FOREIGN KEY (created_by) REFERENCES users (id) ON DELETE SET NULL, CONSTRAINT fk_absences_updated_by FOREIGN KEY (updated_by) REFERENCES users (id) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;