Files
perauset-e2e-mrfzphpz/db/sqlite/0004-fabric-audit.sql
2026-07-11 08:35:02 +02:00

30 lines
954 B
SQL

-- ============================================================
-- Fabric audit event sink — the table Pikku Fabric writes AuditEvent
-- records to. Distinct from the domain `audit_log` (row-change history
-- in 0001/0003): this is the framework-level event stream.
-- Columns mirror the AuditEvent shape (camelCase → snake_case for the
-- CamelCasePlugin kysely).
-- ============================================================
CREATE TABLE audit (
event_id TEXT PRIMARY KEY,
type TEXT NOT NULL,
source TEXT,
outcome TEXT,
occurred_at TEXT NOT NULL DEFAULT (datetime('now')),
function_id TEXT,
wire_type TEXT,
wire_id TEXT,
trace_id TEXT,
transaction_id TEXT,
query_id TEXT,
actor TEXT,
input TEXT,
metadata TEXT
);
CREATE INDEX idx_audit_type ON audit(type);
CREATE INDEX idx_audit_occurred ON audit(occurred_at);
CREATE INDEX idx_audit_function ON audit(function_id);
CREATE INDEX idx_audit_trace ON audit(trace_id);