31 lines
1.3 KiB
SQL
31 lines
1.3 KiB
SQL
-- Phase 06 #23 — Per-capability-use audit table.
|
|
--
|
|
-- Every host-fn call inside a plugin invocation logs one row here so
|
|
-- tenant admins can answer "what did this plugin actually do?" — see
|
|
-- docs/improvement-plan/06-plugin-system/audit-docs.md.
|
|
--
|
|
-- Rows are batch-inserted from the outbox dispatcher via the worker
|
|
-- handler `plugin-capability-use.ts`; the capability-gateway never
|
|
-- writes here directly (keeps the plugin hot-path off the DB).
|
|
|
|
CREATE TABLE "PluginCapabilityUse" (
|
|
"id" TEXT NOT NULL,
|
|
"pluginInvocationId" TEXT NOT NULL,
|
|
"tenantId" TEXT NOT NULL,
|
|
"pluginId" TEXT NOT NULL,
|
|
"capability" TEXT NOT NULL,
|
|
"payloadHash" TEXT,
|
|
"outcome" TEXT NOT NULL,
|
|
"errorCode" TEXT,
|
|
"durationMs" INTEGER,
|
|
"timestamp" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
CONSTRAINT "PluginCapabilityUse_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
CREATE INDEX "PluginCapabilityUse_tenantId_timestamp_idx"
|
|
ON "PluginCapabilityUse" ("tenantId", "timestamp" DESC);
|
|
CREATE INDEX "PluginCapabilityUse_tenantId_pluginId_timestamp_idx"
|
|
ON "PluginCapabilityUse" ("tenantId", "pluginId", "timestamp" DESC);
|
|
CREATE INDEX "PluginCapabilityUse_pluginInvocationId_idx"
|
|
ON "PluginCapabilityUse" ("pluginInvocationId");
|