<?php
declare(strict_types=1);

return function (PDO $pdo): void {
    $pdo->exec("
        CREATE TABLE IF NOT EXISTS security_events (
            id          INTEGER PRIMARY KEY AUTOINCREMENT,
            event_type  TEXT NOT NULL,
            severity    TEXT NOT NULL DEFAULT 'info',
            user_id     INTEGER,
            ip          TEXT,
            details     TEXT,
            created_at  DATETIME DEFAULT CURRENT_TIMESTAMP
        )
    ");
    $pdo->exec("CREATE INDEX IF NOT EXISTS idx_security_events_type    ON security_events(event_type)");
    $pdo->exec("CREATE INDEX IF NOT EXISTS idx_security_events_user    ON security_events(user_id)");
    $pdo->exec("CREATE INDEX IF NOT EXISTS idx_security_events_created ON security_events(created_at)");
};
