-- 013_print_audit.sql: Print Audit plugin (打印审计)

CREATE TABLE IF NOT EXISTS print_events (
    id              INTEGER PRIMARY KEY AUTOINCREMENT,
    device_uid      TEXT NOT NULL,
    document_name   TEXT,
    printer_name    TEXT,
    pages           INTEGER,
    copies          INTEGER DEFAULT 1,
    user_name       TEXT,
    file_size_bytes INTEGER,
    timestamp       TEXT NOT NULL,
    reported_at     TEXT NOT NULL DEFAULT (datetime('now')),
    FOREIGN KEY (device_uid) REFERENCES devices(device_uid)
);

CREATE INDEX IF NOT EXISTS idx_print_events_device ON print_events(device_uid);
CREATE INDEX IF NOT EXISTS idx_print_events_ts ON print_events(timestamp);
